multipage2book.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:multipage_to_book_batch_converter 作者: uml-digitalinitiatives 项目源码 文件源码
def count_pages(input_file):
    """Count the number of pages in a file

    Keyword arguments
    input_file -- the full path to the input file
    """
    count = 0
    if is_pdf.match(input_file):
        with open(input_file, 'rb') as fp:
            count += len(rxcountpages.findall(fp.read()))
        if count == 0:
            pdf_read = PyPDF2.PdfFileReader(input_file)
            count = pdf_read.getNumPages()
            pdf_read = None
    else:
        ops = [
            'identify', '-ping', '-format', "%n\\n", input_file
        ]
        results = do_system_call(ops, return_result=True)
        count = int(results.rstrip().split('\n').pop())

    return count
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号