Optimize: use img2pdf stream instead of repeated copies

This commit is contained in:
James R. Barlow 2016-01-18 20:24:46 -08:00
parent 354e61946e
commit a0952bfca3
2 changed files with 2 additions and 3 deletions

View File

@ -591,9 +591,8 @@ def select_image_layer(
else:
pageinfo = get_pageinfo(image, pdfinfo, pdfinfo_lock)
dpi = round(max(pageinfo['xres'], pageinfo['yres'], options.oversample))
pdf_bytes = img2pdf.convert([image], dpi=dpi)
with open(output_file, 'wb') as pdf:
pdf.write(pdf_bytes)
img2pdf.convert([image], dpi=dpi, outputstream=pdf)
@active_if(options.pdf_renderer == 'hocr')

View File

@ -2,4 +2,4 @@ ruffus>=2.6.3
Pillow>=2.4.0
reportlab>=3.1.44
PyPDF2>=1.25.1
img2pdf>=0.1.5
git+https://github.com/jbarlow83/img2pdf.git@1261741136dcbfed65355ed93f4930617a55feee#egg=img2pdf