[Django]-Django content type of an image file

7👍

imghdr.what will return image format as string (gif, png etc.) if the image is valid, or None otherwise.

Usage:

import imghdr
imghdr.what(value)

In the above example value can be either a file(-like) object or a filename.

Leave a comment