The order of tests in imghdr makes it slow in common cases. Even without any statistics it is quite easy to see that jpeg is the most common format. In imghdr only bmp and png are after it. Also, should png really be the last one? Nearly all digital cameras produce jpegs and handling such images is one big use case for this module. Changing the test order should be easy and have big effect in common use cases.
Naturally it requires a big amount of files. Getting big amount of jpegs is easy. Getting big amount of pbms or rgbs is not so easy. I'll attach two profiling runs showing some difference when test_jpeg and test_exif are moved to be the first tests. The beginnings those outputs show the return value counts.