Image.split broken when image file isn't loaded

Chris Lamb <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
Hi,

Image.split appears to be broken when the image file isn't loaded first.

My testcase is:

  >>> from PIL import Image
  >>> x = Image.open('test.png')
  >>> x.split()
  [..]
  AttributeError: 'NoneType' object has no attribute 'bands'

I think Image.point was broken in the same way recently; the client
workaround of calling Image.load works here too.

Patch attached.


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [email protected]
       `-

_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
fix-split.diff (text/x-patch, 600 B)
diff -urNad python-imaging-1.1.7.orig/PIL/Image.py python-imaging-1.1.7/PIL/Image.py
--- python-imaging-1.1.7.orig/PIL/Image.py	2009-12-09 14:37:37.000000000 +0000
+++ python-imaging-1.1.7/PIL/Image.py	2009-12-09 14:38:13.000000000 +0000
@@ -1494,11 +1494,12 @@
     def split(self):
         "Split image into bands"
 
+        self.load()
+
         if self.im.bands == 1:
             ims = [self.copy()]
         else:
             ims = []
-            self.load()
             for i in range(self.im.bands):
                 ims.append(self._new(self.im.getband(i)))
         return tuple(ims)
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAksfuWoACgkQ5/8uW2NPmiACmgCffsIHOMtPbOetUetTn3p6VKy9
JGMAn2QW1V7CrdCF+hu8noQYSq5GQERm
=rBZh
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.