images of jpg without extension are not displayed

Kivy is using “imghdr” to determine the image type here, and as a fallback it uses the file extension here.

That explains why the image loads fine when it has a file extension, even though “imghdr” can’t find the file type in the file’s content.

I tested on a list of JPEG files, and each time “imghdr” was able to detect the file type each time. That is done here im imghdr. Notably, “imghdr” does not consider the file extension.

$ python
>>> import os, imghdr
... for f in os.listdir('.'):
...     print('%s -- %s' % (f, imghdr.what(f)))

Maybe the JPEG file is missing the “JFIF” or “Exif” string that imghdr is looking for? You could use hexedit to see if one of those string is present at Byte 6 of the image file.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top