mirror of https://github.com/python/cpython.git
bpo-44539: Support recognizing JPEG files without JFIF or Exif markers (GH-26964)
Co-authored-by: moemansour03@gmail.com <m.mansour@tecfrac.com> Co-authored-by: Éric Araujo <merwok@netwok.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
6564656495
commit
3b56b3b97d
|
@ -35,9 +35,11 @@ def what(file, h=None):
|
||||||
tests = []
|
tests = []
|
||||||
|
|
||||||
def test_jpeg(h, f):
|
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'):
|
if h[6:10] in (b'JFIF', b'Exif'):
|
||||||
return 'jpeg'
|
return 'jpeg'
|
||||||
|
elif h[:4] == b'\xff\xd8\xff\xdb':
|
||||||
|
return 'jpeg'
|
||||||
|
|
||||||
tests.append(test_jpeg)
|
tests.append(test_jpeg)
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 525 B |
|
@ -16,6 +16,7 @@
|
||||||
('python.pgm', 'pgm'),
|
('python.pgm', 'pgm'),
|
||||||
('python.pbm', 'pbm'),
|
('python.pbm', 'pbm'),
|
||||||
('python.jpg', 'jpeg'),
|
('python.jpg', 'jpeg'),
|
||||||
|
('python-raw.jpg', 'jpeg'), # raw JPEG without JFIF/EXIF markers
|
||||||
('python.ras', 'rast'),
|
('python.ras', 'rast'),
|
||||||
('python.sgi', 'rgb'),
|
('python.sgi', 'rgb'),
|
||||||
('python.tiff', 'tiff'),
|
('python.tiff', 'tiff'),
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Added support for recognizing JPEG files without JFIF or Exif markers.
|
Loading…
Reference in New Issue