Fix img2pdf 0.2 usage

All tests pass when forced to rely on img2pdf, so seems okay
This commit is contained in:
James R. Barlow
2016-02-05 15:13:26 -08:00
parent e9b87cefcc
commit daa3916430

View File

@@ -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))