Skip to content

Commit 97db05d

Browse files
committed
SF python#75103: imghdr -- identify JPEGs in EXIF format
1 parent dd3e6cb commit 97db05d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Doc/lib/libimghdr.tex

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ \section{\module{imghdr} ---
3131
\lineii{'tiff'}{TIFF Files}
3232
\lineii{'rast'}{Sun Raster Files}
3333
\lineii{'xbm'}{X Bitmap Files}
34-
\lineii{'jpeg'}{JPEG data in JFIF format}
34+
\lineii{'jpeg'}{JPEG data in JFIF or Exif formats}
3535
\lineii{'bmp'}{BMP files}
3636
\lineii{'png'}{Portable Network Graphics}
3737
\end{tableii}
3838

39+
\versionadded[Exif detection]{2.5}
40+
3941
You can extend the list of file types \module{imghdr} can recognize by
4042
appending to this variable:
4143

Lib/imghdr.py

+7
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def test_jpeg(h, f):
101101

102102
tests.append(test_jpeg)
103103

104+
def test_exif(h, f):
105+
"""JPEG data in Exif format"""
106+
if h[6:10] == 'Exif':
107+
return 'jpeg'
108+
109+
tests.append(test_exif)
110+
104111
def test_bmp(h, f):
105112
if h[:2] == 'BM':
106113
return 'bmp'

Misc/NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Extension Modules
3333
Library
3434
-------
3535

36+
- The imghdr module now detects Exif files.
37+
3638
- StringIO.truncate() now correctly adjusts the size attribute.
3739
(Bug #951915).
3840

0 commit comments

Comments
 (0)