Forums

Python Image Library

I'm trying to use the Image class from the Python Image Library; I gather the package is installed because "import PIL" and "from PIL import Image" works without difficulty, but I'm still getting NoneType when trying to refer to the Image class.

Any ideas what could be causing this? Normally I'd resolve this by installing PIL in my gluon.contribs, but since the import isn't failing this should mean the package is already installed... right?

Hmmm... narrowed it down to a problem in FPDF - the qrcode module uses Image without difficulty. I expect I can resolve this with some brute force without admin intervention.

For anyone encountering this problem in the future, the fix is to explicitly import Image in the _parsejpg function of FPDF (rather than in the file header as is customary): just insert 'from PIL import Image' after the _parsejpg function def.

Or better yet, just use the .png format for your files.