From ce4d12711ab8674fad84bb65f26f17fcc7749010 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 18 Jul 2013 08:16:29 +0530 Subject: [PATCH] Correctly identify JPEG files that have no headers --- src/calibre/utils/imghdr.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/utils/imghdr.py b/src/calibre/utils/imghdr.py index c899a5be95..c4070f072e 100644 --- a/src/calibre/utils/imghdr.py +++ b/src/calibre/utils/imghdr.py @@ -26,6 +26,10 @@ def what(file, h=None): finally: if f: f.close() + # There exist some jpeg files with no headers, only the starting two bits + # If we cannot identify as anything else, identify as jpeg. + if h[:2] == b'\xff\xd8': + return 'jpeg' return None