[Image-SIG] Re: Image.open doesn't close file before raising IOError "cannot identify image file"
Sun, 13 Apr 2003 14:27:20 +0200
"aut imagesig" <firstname.lastname@example.org> wrote:
> im = Image.open(filename)
> except IOError:
that doesn't work if the file doesn't exist.
a more robust solution (which doesn't require any changes to
the library) is to open the file at the application level:
file = open(filename, "rb")
# the file doesn't appear to exist
im = Image.open(file)
# not an image file; get rid of it