From daa3916430558c1923b2201bfc9cd6336043cf4c Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 5 Feb 2016 15:13:26 -0800 Subject: [PATCH] Fix img2pdf 0.2 usage All tests pass when forced to rely on img2pdf, so seems okay --- ocrmypdf/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ocrmypdf/main.py b/ocrmypdf/main.py index 04eaf990..fbd13769 100755 --- a/ocrmypdf/main.py +++ b/ocrmypdf/main.py @@ -165,9 +165,6 @@ parser.add_argument( '--skip-big', type=float, metavar='MPixels', help="skip OCR on pages larger than the specified amount of megapixels, " "but include skipped pages in final output") -# parser.add_argument( -# '--exact-image', action='store_true', -# help="Use original page from PDF without re-rendering") advanced = parser.add_argument_group( "Advanced", @@ -594,12 +591,15 @@ def select_image_layer( pageinfo = get_pageinfo(image, pdfinfo, pdfinfo_lock) dpi = round(max(pageinfo['xres'], pageinfo['yres'], options.oversample)) - imgsize = '{0}dpix{1}dpi'.format(dpi, dpi) + imgsize = ((img2pdf.ImgSize.dpi, dpi), (img2pdf.ImgSize.dpi, dpi)) + layout_fun = img2pdf.get_layout_fun(None, imgsize, None, None, None) - with open(output_file, 'wb') as pdf: + with open(image, 'rb') as imfile, \ + open(output_file, 'wb') as pdf: + rawdata = imfile.read() pdf.write(img2pdf.convert( - [image], producer="img2pdf", with_pdfrw=False, + rawdata, producer="img2pdf", with_pdfrw=False, layout_fun=layout_fun))