[Image-SIG] crop is a little too lazy (with patch)
Douglas Bagnall
douglas at paradise.net.nz
Mon Sep 24 03:48:49 CEST 2007
A cropped image does not return a pixel access object when load()ed.
This seems to be a simple oversight.
>>> im = Image.new('L',(50,50))
>>> im.load()
<PixelAccess object at 0xb7d900f0>
>>> im2 = im.crop((0, 0, 20, 20))
>>> im2.load()
None
There is an easy workaround:
>>> im2.im.pixel_access()
<PixelAccess object at 0xb7d900f0>
and the patch below cures the problem.
douglas
---------------------------------------------
--- Image-old.py 2007-09-24 13:19:30.000000000 +1200
+++ Image-new.py 2007-09-24 13:19:17.000000000 +1200
@@ -1666,6 +1666,8 @@
if self.__crop:
self.im = self.im.crop(self.__crop)
self.__crop = None
+ if self.im:
+ return self.im.pixel_access(self.readonly)
# FIXME: future versions should optimize crop/paste
# sequences!
More information about the Image-SIG
mailing list