diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-06-26 16:27:57 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-06-26 16:27:57 (GMT) |
commit | 2f60820f4c1bdfce75f30ddc53d97587a3256dcf (patch) | |
tree | 6b115cf76be50645d161ebde14913202bbd64403 | |
parent | a157867a3d10e4ee802fa2fd910f2dda383fa823 (diff) | |
download | cpython-2f60820f4c1bdfce75f30ddc53d97587a3256dcf.zip cpython-2f60820f4c1bdfce75f30ddc53d97587a3256dcf.tar.gz cpython-2f60820f4c1bdfce75f30ddc53d97587a3256dcf.tar.bz2 |
#20295: Teach imghdr to recognize OpenEXR format images.
Patch by Martin Vignali, test by Claudiu Popa.
-rw-r--r-- | Doc/library/imghdr.rst | 5 | ||||
-rw-r--r-- | Doc/whatsnew/3.5.rst | 6 | ||||
-rw-r--r-- | Lib/imghdr.py | 6 | ||||
-rw-r--r-- | Lib/test/imghdrdata/python.exr | bin | 0 -> 2635 bytes | |||
-rw-r--r-- | Lib/test/test_imghdr.py | 1 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
6 files changed, 20 insertions, 0 deletions
diff --git a/Doc/library/imghdr.rst b/Doc/library/imghdr.rst index 06faa88..c60df24 100644 --- a/Doc/library/imghdr.rst +++ b/Doc/library/imghdr.rst @@ -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. diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst index 1b4253c..9fff48c 100644 --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -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 --------- diff --git a/Lib/imghdr.py b/Lib/imghdr.py index fe77e49..b267925 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -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 Binary files differnew file mode 100644 index 0000000..773c81e --- /dev/null +++ b/Lib/test/imghdrdata/python.exr diff --git a/Lib/test/test_imghdr.py b/Lib/test/test_imghdr.py index e2a1aca..b54daf8 100644 --- a/Lib/test/test_imghdr.py +++ b/Lib/test/test_imghdr.py @@ -18,6 +18,7 @@ TEST_FILES = ( ('python.tiff', 'tiff'), ('python.xbm', 'xbm'), ('python.webp', 'webp'), + ('python.exr', 'exr'), ) class UnseekableIO(io.FileIO): @@ -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. |