Determining if file is valid image file
Terry Reedy
tjreedy at udel.edu
Thu Aug 2 16:36:08 EDT 2007
"Jarek Zgoda" <jzgoda at usun.pl> wrote in message
news:f8tbd6$rnh$1 at nemesis.news.tpi.pl...
André napisa³(a):
>>>> Other than installing PIL, is there a "simple" way using Python only
>>>> to determine if a file is a valid image file?
[...]
> Be aware that broken images (i.e. partially downloaded) in many cases
> pass the imghdr.what() test.
To put it another way, the only way to determine whether a coded file is
valid may be to decode it. And even then, it may be corrupted in the sense
that the decoded version may have artifacts not in the original. I have
seen the latter both in jpeg images and movie DVDs.
tjr
More information about the Python-list
mailing list