Search code examples
pythonimagecross-platformmime

How to guess image mime type?


How can I guess an image's mime type, in a cross-platform manner, and without any external libraries?


Solution

  • If you know in advance that you only need to handle a limited number of file formats you can use the imghdr.what function.