summaryrefslogtreecommitdiffstats
path: root/Lib/imghdr.py
diff options
context:
space:
mode:
authorMohamad Mansour <66031317+mohamadmansourX@users.noreply.github.com>2021-07-20 18:56:57 (GMT)
committerGitHub <noreply@github.com>2021-07-20 18:56:57 (GMT)
commit3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b (patch)
treefb444a949aef36f18b00b457b2fefdcba24c0023 /Lib/imghdr.py
parent6564656495d456a1bcc1aaa06abfc696209f37b2 (diff)
downloadcpython-3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b.zip
cpython-3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b.tar.gz
cpython-3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b.tar.bz2
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>
Diffstat (limited to 'Lib/imghdr.py')
-rw-r--r--Lib/imghdr.py4
1 files changed, 3 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)