[issue16512] imghdr doesn't support jpegs with an ICC profile

Kovid Goyal report at bugs.python.org
Wed Mar 20 07:23:29 CET 2013


Kovid Goyal added the comment:

The attached patch is insufficient, for example, it fails on http://nationalpostnews.files.wordpress.com/2013/03/budget.jpeg?w=300&h=1571

Note that the linux file utility identifies a files as "JPEG Image data" if the first two bytes of the file are \xff\xd8.

A slightly stricter test that catches more jpeg files:

def test_jpeg(h, f):
    if (h[6:10] in (b'JFIF', b'Exif')) or (h[:2] == b'\xff\xd8' and b'JFIF' in h[:32]):
        return 'jpeg'

----------
nosy: +kovid

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16512>
_______________________________________


More information about the Python-bugs-list mailing list