Determining if file is valid image file

André andre.roberge at gmail.com
Thu Aug 2 10:40:45 EDT 2007


On Aug 2, 11:34 am, Jarek Zgoda <jzg... at o2.usun.pl> wrote:
> 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?
>
> >> I'd be happy if I could at least identify valid images files for gif,
> >> jpeg and png.   Pointers to existing modules or examples would be
> >> appreciated.
>
> >> The reason why I'd prefer not using PIL is that I'd like to bundle
> >> such a function/module in my app.
>
> >> André
>
> > I should have added: I'm interesting in validating the file *content*
> > - not the filename :-)
>
> Is the module imghdr enough for your needs?
>

Yes, thanks.


> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: zg... at jabber.aster.pl | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)





More information about the Python-list mailing list