diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/imghdr.py | 4 | ||||
-rw-r--r-- | Lib/test/imghdrdata/python-raw.jpg | bin | 0 -> 525 bytes | |||
-rw-r--r-- | Lib/test/test_imghdr.py | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/Lib/imghdr.py b/Lib/imghdr.py index 6e01fd8..afcb677 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -35,9 +35,11 @@ def what(file, h=None): tests = [] def test_jpeg(h, f): - """JPEG data in JFIF or Exif format""" + """JPEG data with JFIF or Exif markers; and raw JPEG""" if h[6:10] in (b'JFIF', b'Exif'): return 'jpeg' + elif h[:4] == b'\xff\xd8\xff\xdb': + return 'jpeg' tests.append(test_jpeg) diff --git a/Lib/test/imghdrdata/python-raw.jpg b/Lib/test/imghdrdata/python-raw.jpg Binary files differnew file mode 100644 index 0000000..11940b3 --- /dev/null +++ b/Lib/test/imghdrdata/python-raw.jpg diff --git a/Lib/test/test_imghdr.py b/Lib/test/test_imghdr.py index b2d1fc8..ca0a0b2 100644 --- a/Lib/test/test_imghdr.py +++ b/Lib/test/test_imghdr.py @@ -16,6 +16,7 @@ TEST_FILES = ( ('python.pgm', 'pgm'), ('python.pbm', 'pbm'), ('python.jpg', 'jpeg'), + ('python-raw.jpg', 'jpeg'), # raw JPEG without JFIF/EXIF markers ('python.ras', 'rast'), ('python.sgi', 'rgb'), ('python.tiff', 'tiff'), |