View Single Post
Old 07-22-2013, 03:23 PM   #560
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,645
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,

I will add this change to kindleunpack.py as well so that it operates correctly even without operating inside a calibre environment.

It will appear in the upcoming KindleUnpack v0.63.

Thank you!

Kevin

Quote:
Originally Posted by NiLuJe View Post
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"
KevinH is offline   Reply With Quote