[reportlab-users] Images in PDFs in Google Appengine

Robin Becker robin at reportlab.com
Mon Aug 18 06:11:09 EDT 2008


john at thinkwave.com wrote:

> Hello

>

> I am using Google Appengine, and am successfully generating text-based PDF documents using Platypus and ReportLab. Now, I'd like to include images in the reports, and am getting stuck.

>

> First: Google does not support PIL. It does provide it's own module to save an image to a blobproperty as a jpeg file. From what I understand, if I use a jpeg file from the datastore, it should render, even if PIL is not installed?

>

> But I'm having problems getting this to work. If I assign the model.blob value to a variable, and place the variable

> in the table ([item]) - I get UnicodeDecodeError exceptions. If I try

> to retrieve the image from my handler (which outputs the image as a mimetype image/jpg) - I get Imaging Library not

> available errors.

>

> Can someone provide me with some pointers how I'd go about successfully taking a jpeg stored in a blobproperty, and getting it included into a platypus table, without having the application start loading PIL modules? Thanks -

>

> johnP

>

........
Most images can be supported as internal objects/files, but the problem is that
we then have use PIL to detect the image type/size of the file. If it's a jpeg
we revert to using it directly so no conversion to rgb is done.

We have a check for jpeg info in python so it should not be required to use PIL.

If you want to use an image in platypus you normally have to create an
ImageFlowable ie

ImageFlowable(filename, width=None, height=None)

filename can be a filelike object, but currently we don't support specifying
that it contains an image of a specific type. I suppose we could complicate
matters to allow that to be done so then you can wrap your blob in something
that looks like a file, but also indicates that it's a natively supported jpeg.
--
Robin Becker


More information about the reportlab-users mailing list