I use PIL to open AREA files from NOAA on a regular basis. In the last batch of images I received, the image.open() command simply does not work. Here is a simple code I wrote which yields the same results. It will open, rotate, and perform normal tasks with a file from a month ago, and not with a file from today.
from PIL import Image
im = Image.open("path/to/file")
im.show()
Here's the error:
File "image_goes.py", line 2, in <module>
im = Image.open("path/to/file")
File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1980, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
Here's what I have tried:
My hypothesis was that there was a problem with our downloading script and that it was not fully downloading the file, but that hypothesis is rejected by the fact that the new files are the correct size and that I manually downloaded them using an FTP client and got the same results.
My only other theory is that there is a problem with the NOAA files today or that they have been changed in such a way that PIL can no longer handle them, but I find that unlikely.
Any help greatly appreciated, Thanks
Image. open() Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the load() method).
PIL's built-in show() method is the simplest possible version of the "script some other program to show it". (On earlier Windows systems you'd end up with a whole bunch of MSPaint windows.)
Maybe be the content is not actually synced to the disk. try Image.open(open("path/to/file", 'rb'))
For
im = Image.open("path/to/file")
Try
im = Image.open(r"path/to/file")
That is, put a r
before the path string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With