Hi all,
I've been struggling with this error for several days with little headway. Basically, I'm trying to read in an image file and then use PIL to preform a specific operation on it. (my end goal is to preform a PIL paste operation).
However, whenever I load my image in, and then invoke the load() method on it (operations like show(), paste(), resize(), etc. all invoke the load() method), I get a weird NoneType has no attribute read error.
I'm using PIL 1.1.7 and have reproduced this error on both OSX 10.6 and Ubuntu 10.04. Below is the most basic ipython code that I can enter to produce the error.
Has anyone see this type of situation before?
Any help is much appreciated.
In [1]: import os
In [2]: try:
...: from PIL import Image
...: except ImportError:
...: import Image
...:
In [3]: from django.conf import settings
In [4]: bgImageFileHash = "d41d8cd98f00b204e9800998ecf8427e"
In [5]: bgImageFilePath = os.path.join(settings.MEDIA_ROOT,'uploads',"%s.jpg" % (bgImageFileHash))
In [6]: print bgImageFilePath
------> print(bgImageFilePath )
/Users/test/Sites/env/mysite/proj/mysite/../mysite/media/uploads/d41d8cd98f00b204e9800998ecf8427e.jpg
In [7]: bgImageImage=Image.open(bgImageFilePath)
In [8]: bgImageImage.verify()
In [9]: bgImageImage.load()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/Users/test/Sites/env/mysite/proj/mysite/<ipython console> in <module>()
/Users/test/Sites/env/mysite/lib/python2.6/site-packages/PIL/ImageFile.pyc in load(self)
168 read = self.load_read
169 except AttributeError:
--> 170 read = self.fp.read
171
172 try:
AttributeError: 'NoneType' object has no attribute 'read'