[reportlab-users] Still confused about PIL Image objects

Ian Sparks Ian.Sparks at etrials.com
Wed May 11 09:03:52 EDT 2005

It used to be that PIL Image objects could be passed to the canvas.drawImage() method. Then there was a change in ReportLab which made this fail with an error related to "getRGBData()".

I understand that this was done to reduce the requirement to have PIL installed. Fair enough.

I'm using reportlab 1.20. I have a PIL Image object that I want to pass to canvas.drawImage(). I'm using PIL because I often need to resize or modify the image in some way before I write it into the PDF.

Right now I'm doing this :

		#im is the PIL Image object
            filename = 'temp_im.bmp'
            im.save(filename) #This is an annoying hack, save to a file to get it re-imported  
            os.remove(filename) #Remove it again

There has to be a better way. Someone please enlighten me?

More information about the reportlab-users mailing list