Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f60820

Browse files
committed
#20295: Teach imghdr to recognize OpenEXR format images.
Patch by Martin Vignali, test by Claudiu Popa.
1 parent a157867 commit 2f60820

6 files changed

Lines changed: 20 additions & 0 deletions

File tree

Doc/library/imghdr.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ from :func:`what`:
5050
+------------+-----------------------------------+
5151
| ``'webp'`` | WebP files |
5252
+------------+-----------------------------------+
53+
| ``'exr'`` | OpenEXR Files |
54+
+------------+-----------------------------------+
55+
56+
.. versionadded:: 3.5
57+
The *exr* format was added.
5358

5459
.. versionchanged:: 3.5
5560
The *webp* type was added.

Doc/whatsnew/3.5.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ doctest
141141
*module* contains no docstrings instead of raising :exc:`ValueError`
142142
(contributed by Glenn Jones in :issue:`15916`).
143143

144+
imghdr
145+
------
146+
147+
* :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_
148+
format (contributed by Martin vignali and Cladui Popa in :issue:`20295`).
149+
144150
importlib
145151
---------
146152

Lib/imghdr.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def test_webp(h, f):
116116

117117
tests.append(test_webp)
118118

119+
def test_exr(h, f):
120+
if h.startswith(b'\x76\x2f\x31\x01'):
121+
return 'exr'
122+
123+
tests.append(test_exr)
124+
119125
#--------------------#
120126
# Small test program #
121127
#--------------------#

Lib/test/imghdrdata/python.exr

2.57 KB
Binary file not shown.

Lib/test/test_imghdr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
('python.tiff', 'tiff'),
1919
('python.xbm', 'xbm'),
2020
('python.webp', 'webp'),
21+
('python.exr', 'exr'),
2122
)
2223

2324
class UnseekableIO(io.FileIO):

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Core and Builtins
103103
Library
104104
-------
105105

106+
- Issue #20295: imghdr now recognizes OpenEXR format images.
107+
106108
- Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
107109
files closing. Patch by Claudiu Popa.
108110

0 commit comments

Comments
 (0)