View Single Post
Old 07-17-2013, 01:01 PM   #556
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
That said, there's no JFIF, EXIF or 8BIM anywhere in that file, so Kovid's tweaked imghdr doesn't catch it either. To keep false-positives at bay, I tweaked my extra check a bit:

Code:
                # imghdr only checks for JFIF or Exif JPEG files. Apparently, there are some with only the magic JPEG bytes out there...
                # ImageMagick handle those, so, do it too.
                if imgtype is None and data[0:2] == b'\xFF\xD8':
                    # Get last non-null bytes
                    last = len(data)
                    while (data[last-1:last] == b'\x00'):
                        last-=1
                    # Be extra safe, check the trailing bytes, too.
                    if data[last-2:last] == b'\xFF\xD9':
                        imgtype = "jpeg"
NiLuJe is offline   Reply With Quote