[reportlab-users] Writing smaller image-only PDFs

Nicholas Watmough nickw at deakin.edu.au
Thu Feb 9 01:27:50 EST 2006


Each JPEG is about 0.5MB, so the combined size would be about 5.5MB.

However, I tried saving the JPEGs individually through the commercial 
tool (Omnipage), and the JPEGs were the same size as when saved through 
Python. But the imge-only PDF produced by Omnipage was 0.4MB, and the 
one produced through reportlab was 7.8MB.

Maybe there is some way to reduce the JPEG file size?

Nick

matt wilbert wrote:
> How big are the JPEGs altogether before they get put into the PDF, 
> compared to the size of the PDF?
>
> Matt
>
> On 2/8/06, *Nicholas Watmough* < nickw at deakin.edu.au 
> <mailto:nickw at deakin.edu.au>> wrote:
>
>     Hi,
>
>     I am trying to scan a number of pages, then write the output to a PDF
>     using reportlab. The size of the PDFs generated is much larger than
>     would seem necessary, but I'm not sure why. I've tried to reduce the
>     file size, but it doesn't seem to work.
>
>     I am using the Python TWAIN module to scan the images, which
>     passes the
>     images in BMP format. I use the Python Image Library to open the BMP,
>     and write the PIL object to the PDF using drawInlineImage(). I tried
>     changing to using drawImage(), which required me to wrap the image
>     in an
>     ImageReader object, but this did not decrease the output PDF file
>     size.
>
>     The produced PDF file size was approx 2MB.
>
>     I tried to reduce this by using JPEGs. So I saved my BMPs into JPEGs
>     (using an StringIO class), then reopened the JPEGs using the PIL, and
>     wrote the PIL object to the PDF using drawInlineImage().
>
>     The resulting PDF file size was 7.8MB.
>
>     When I turned on page compression, the file size was reduced to 6.8MB.
>
>     The PDF I am generating only has 11 pages (11 images).
>
>     When I try doing the same thing using a commercial tool (Omnipage), to
>     do the scanning and production of the image-only PDF, the
>     resultant file
>     size is 0.4MB.
>
>     While I realise that an open source tool may not be able to
>     achieve the
>     same reduction level as a commercial tool, the file sizes I am getting
>     using Python seem too large. Particularly as I am getting larger
>     output
>     for JPEGs than I am for BMPs.
>
>     Does anyone know how I can reduce the file size of my produced
>     PDFs? I
>     suspect I may be doing something wrong with the JPEGs, but not
>     really sure.
>
>     Nick
>     _______________________________________________
>     reportlab-users mailing list
>     reportlab-users at reportlab.com <mailto:reportlab-users at reportlab.com>
>     http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>   


More information about the reportlab-users mailing list