Identify image type in Python

There is a standard module for this called imghdr. It's usage is very simple:

from imghdr import what
what('~/images/girls.png')
'png'
comments powered by Disqus