[reportlab-users] Image-Compression: drawImage() using PIL -> PDF very large

Robin Becker reportlab-users@reportlab.com
Thu, 18 Mar 2004 17:09:36 +0000

In article <40598259.3070107@truckport.de>, Patrick Ulmer
<ulmer@truckport.de> writes

Patrick I have made some changes to the back end image processing so
that where possible we use JPEGS directly which should avoid the problem
you report. The changed files are in CVS right now, but if you want I
can package up the changes and email them to your for testing.

>I have a size-problem with my pdf-file. I use reportlab 1.18 becaus of 
>PIL. When I include a jpeg-file with drawImage(), the pdf-size is good, 
>because the compressed image is inserted as it is. When I insert a 
>PIL-jpeg-image, the rawdata compressed using zlib is inserted and the 
>pdf-size is extrem larger. This is my source:
># load data from zope
>logo  = getattr(self.REQUEST.PARENTS[0].images.formulare, "headline.jpg")
>img = PIL_Image.open(cStringIO.StringIO(str(logo.data)))
># draw image
>c.drawImage(img, 0, 0)
>How can I solve this Problem?
>1.) hack pdfimages.py?
>2.) save img as tempfile and use c.drawImage(tmp, 0, 0)?
>3.) somethind else?
>reportlab-users mailing list

Robin Becker