Kaydet (Commit) 2f60820f authored tarafından R David Murray's avatar R David Murray

#20295: Teach imghdr to recognize OpenEXR format images.

Patch by Martin Vignali, test by Claudiu Popa.
üst a157867a
...@@ -50,6 +50,11 @@ from :func:`what`: ...@@ -50,6 +50,11 @@ from :func:`what`:
+------------+-----------------------------------+ +------------+-----------------------------------+
| ``'webp'`` | WebP files | | ``'webp'`` | WebP files |
+------------+-----------------------------------+ +------------+-----------------------------------+
| ``'exr'`` | OpenEXR Files |
+------------+-----------------------------------+
.. versionadded:: 3.5
The *exr* format was added.
.. versionchanged:: 3.5 .. versionchanged:: 3.5
The *webp* type was added. The *webp* type was added.
......
...@@ -141,6 +141,12 @@ doctest ...@@ -141,6 +141,12 @@ doctest
*module* contains no docstrings instead of raising :exc:`ValueError` *module* contains no docstrings instead of raising :exc:`ValueError`
(contributed by Glenn Jones in :issue:`15916`). (contributed by Glenn Jones in :issue:`15916`).
imghdr
------
* :func:`~imghdr.what` now recognizes the `OpenEXR <http://www.openexr.com>`_
format (contributed by Martin vignali and Cladui Popa in :issue:`20295`).
importlib importlib
--------- ---------
......
...@@ -116,6 +116,12 @@ def test_webp(h, f): ...@@ -116,6 +116,12 @@ def test_webp(h, f):
tests.append(test_webp) tests.append(test_webp)
def test_exr(h, f):
if h.startswith(b'\x76\x2f\x31\x01'):
return 'exr'
tests.append(test_exr)
#--------------------# #--------------------#
# Small test program # # Small test program #
#--------------------# #--------------------#
......
...@@ -18,6 +18,7 @@ TEST_FILES = ( ...@@ -18,6 +18,7 @@ TEST_FILES = (
('python.tiff', 'tiff'), ('python.tiff', 'tiff'),
('python.xbm', 'xbm'), ('python.xbm', 'xbm'),
('python.webp', 'webp'), ('python.webp', 'webp'),
('python.exr', 'exr'),
) )
class UnseekableIO(io.FileIO): class UnseekableIO(io.FileIO):
......
...@@ -103,6 +103,8 @@ Core and Builtins ...@@ -103,6 +103,8 @@ Core and Builtins
Library Library
------- -------
- Issue #20295: imghdr now recognizes OpenEXR format images.
- Issue #21729: Used the "with" statement in the dbm.dumb module to ensure - Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
files closing. Patch by Claudiu Popa. files closing. Patch by Claudiu Popa.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment