[reportlab-users] Appengine - Reportlab (Get Photo from Model)

Henning von Bargen H.vonBargen at t-p.com
Tue Oct 5 03:20:26 EDT 2010



> I?m getting errors like this one:

> File "C:\Users\hp\workspace\x-ray\src\principal.py", line 441, in post

> image = canvas.ImageReader(StringIO.StringIO(user.photo)) File

> "reportlab.zip\reportlab\lib\utils.py", line 588, in *init* File

> "reportlab.zip\reportlab\lib\utils.py", line 582, in *init* RuntimeError:

> Imaging Library not available, unable to import bitmaps only jpegs

> fileName=<StringIO.StringIO instance at 0x04A5A030>

> identity=[ImageReader at 0x4a62290].


Look at the exception traceback. A RuntimeError is thrown in utils.py.

The following code in utils.py is bad coding style IMHO
as it hides the actual cause and results in a possibly misleading message:

class ImageReader(object):
...
def __init__(self, fileName):
...
if haveImages:
...
else:
from reportlab.pdfbase.pdfutils import readJPEGInfo
try:
self._width,self._height,c=readJPEGInfo(self.fp)
except:
raise RuntimeError('Imaging Library not available, unable to import bitmaps only jpegs')
...

For a test, you should remove the exception handling shown here.
Then you'll see what exactly goes wrong in pdfutils.readJPEGInfo.

Just to be sure, you should also dump the actual blob content to a file.
Maybe it has a jpeg file suffix but isn't standard JPEG?

HTH
Henning


More information about the reportlab-users mailing list