Currently, pdfimages.py converts all inline images to
RGB before embedding them into the PDF. Because I
frequently use multiple 1 bit inline images in
documents, both the CPU overhead of conversion and the
increased size of the created PDF are significant.
The attached diff uses PIL to see if the mode of the
image is 'L' (grayscale) or '1' (black and white). If
so, it embeds the image using the appropriate PDF
encoding scheme without converting it.
All other image modes (including RGB) are converted to
RGB and encoded as before.
This diff file also includes patches for request IDs
884721 ("global name sys not defined") and 887166
("print" in pdfimages.py causes CGI problems). Both of
these patches are specific to Reportlab v1.19.
Log in to post a comment.