]> granicus.if.org Git - python/commitdiff
#20295: Teach imghdr to recognize OpenEXR format images.
authorR David Murray <rdmurray@bitdance.com>
Thu, 26 Jun 2014 16:27:57 +0000 (12:27 -0400)
committerR David Murray <rdmurray@bitdance.com>
Thu, 26 Jun 2014 16:27:57 +0000 (12:27 -0400)
Patch by Martin Vignali, test by Claudiu Popa.

Doc/library/imghdr.rst
Doc/whatsnew/3.5.rst
Lib/imghdr.py
Lib/test/imghdrdata/python.exr [new file with mode: 0644]
Lib/test/test_imghdr.py
Misc/NEWS

index 06faa883d3f89c5741908c3dd47ccf08abed9514..c60df24c5a17e1d1150570c6411124215298a13f 100644 (file)
@@ -50,6 +50,11 @@ from :func:`what`:
 +------------+-----------------------------------+
 | ``'webp'`` | WebP files                        |
 +------------+-----------------------------------+
+| ``'exr'``  | OpenEXR Files                     |
++------------+-----------------------------------+
+
+.. versionadded:: 3.5
+   The *exr* format was added.
 
 .. versionchanged:: 3.5
    The *webp* type was added.
index 1b4253ce7280c83d40b5f04164b76133cb493313..9fff48cf55f96890799e09b15db3b8bef2e48573 100644 (file)
@@ -141,6 +141,12 @@ doctest
   *module* contains no docstrings instead of raising :exc:`ValueError`
   (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
 ---------
 
index fe77e495fb6ae3d7d9ea962141399b6f798d3476..b26792539d5be169b8a8fbc64cb46ffd49a14fcc 100644 (file)
@@ -116,6 +116,12 @@ def test_webp(h, f):
 
 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 #
 #--------------------#
diff --git a/Lib/test/imghdrdata/python.exr b/Lib/test/imghdrdata/python.exr
new file mode 100644 (file)
index 0000000..773c81e
Binary files /dev/null and b/Lib/test/imghdrdata/python.exr differ
index e2a1acab32288e639097e2bdedb89a5b0267adc3..b54daf8e2ca1a77aea49cbff6db2ee2c010c9d32 100644 (file)
@@ -18,6 +18,7 @@ TEST_FILES = (
     ('python.tiff', 'tiff'),
     ('python.xbm', 'xbm'),
     ('python.webp', 'webp'),
+    ('python.exr', 'exr'),
 )
 
 class UnseekableIO(io.FileIO):
index 9ae200a61e674a82f31fd8ed09edefb3673e0a25..1cd7d58ff05870c562bce82cbc4c2339bc3d8ea4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -103,6 +103,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #20295: imghdr now recognizes OpenEXR format images.
+
 - Issue #21729: Used the "with" statement in the dbm.dumb module to ensure
   files closing.  Patch by Claudiu Popa.