cpython: #20295: Teach imghdr to recognize OpenEXR format images.
http://hg.python.org/cpython/rev/71b9a841119a changeset: 91426:71b9a841119a parent: 91424:9f51e71bf761 user: R David Murray <rdmurray@bitdance.com> date: Thu Jun 26 12:27:57 2014 -0400 summary: #20295: Teach imghdr to recognize OpenEXR format images. Patch by Martin Vignali, test by Claudiu Popa. files: Doc/library/imghdr.rst | 5 +++++ Doc/whatsnew/3.5.rst | 6 ++++++ Lib/imghdr.py | 6 ++++++ Lib/test/imghdrdata/python.exr | Bin Lib/test/test_imghdr.py | 1 + Misc/NEWS | 2 ++ 6 files changed, 20 insertions(+), 0 deletions(-) diff --git a/Doc/library/imghdr.rst b/Doc/library/imghdr.rst --- a/Doc/library/imghdr.rst +++ b/Doc/library/imghdr.rst @@ -50,6 +50,11 @@ +------------+-----------------------------------+ | ``'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 --- a/Doc/whatsnew/3.5.rst +++ b/Doc/whatsnew/3.5.rst @@ -141,6 +141,12 @@ *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 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -116,6 +116,12 @@ 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 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..773c81ee1fb850cdbb6cccd3ae5edabb80146481 GIT binary patch [stripped] diff --git a/Lib/test/test_imghdr.py b/Lib/test/test_imghdr.py --- a/Lib/test/test_imghdr.py +++ b/Lib/test/test_imghdr.py @@ -18,6 +18,7 @@ ('python.tiff', 'tiff'), ('python.xbm', 'xbm'), ('python.webp', 'webp'), + ('python.exr', 'exr'), ) class UnseekableIO(io.FileIO): diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -103,6 +103,8 @@ 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. -- Repository URL: http://hg.python.org/cpython
participants (1)
-
r.david.murray