Car insurance

Arquivo

Arquivo de 22, Maio, 2009

Python: Detectar o formato de uma imagem

22, Maio, 2009 Nenhum comentário

Como detectar o formato ou tipo  de uma imagem em python?

Numa breve pesquisa no Google encontrei a biblioteca imghdr

"imghdr — Determine the type of an image"

Ou seja, por exemplo:

>>> import imghdr
>>> imghdr.what('minha_imagem.gif')

RESULTADO:
'gif'

fonte: http://docs.python.org/library/imghdr.html