[reportlab-users] problem with PIL 1.1.7 and ReportLab 2.2
Robin Becker
robin at reportlab.com
Mon Dec 14 05:53:42 EST 2009
On 11/12/2009 18:22, Bill Janssen wrote:
.........
> Unfortunately, PIL 1.1.7 final is out, and widely distributed. I'm sure
> 1.1.8 will eventually have a fix for this, but ReportLab will still
> continue to break when combined with the buggy 1.1.7. Just calling
> load() in the ReportLab code before calling split() should work fine for
> all versions of PIL.
>
> Bill
.........
Bill,
can you try the effect of this patch
Index: /code/reportlab/lib/utils.py
===================================================================
--- /code/reportlab/lib/utils.py (revision 3616)
+++ /code/reportlab/lib/utils.py (working copy)
@@ -341,7 +341,6 @@
except ImportError:
Image = None
haveImages = Image is not None
- if haveImages: del Image
try:
from cStringIO import StringIO as __StringIO
@@ -519,8 +518,7 @@
def _isPILImage(im):
try:
- from PIL.Image import Image
- return isinstance(im,Image)
+ return isinstance(im,Image.Image)
except ImportError:
return 0
@@ -598,8 +596,7 @@
from javax.imageio import ImageIO
return ImageIO.read(fp)
else:
- import PIL.Image
- return PIL.Image.open(fp)
+ return Image.open(fp)
def _jpeg_fh(self):
fp = self.fp
@@ -644,6 +641,7 @@
im = self._image
mode = self.mode = im.mode
if mode=='RGBA':
+ if Image.VERSION.startswith('1.1.7'): im.load()
self._dataA = ImageReader(im.split()[3])
im = im.convert('RGB')
self.mode = 'RGB'
ie we check for the version of the Image module; the other changes are to make
the import of PIL just once.
--
Robin Becker
More information about the reportlab-users
mailing list