changeset: 91426:71b9a841119a parent: 91424:9f51e71bf761 user: R David Murray date: Thu Jun 26 12:27:57 2014 -0400 files: Doc/library/imghdr.rst Doc/whatsnew/3.5.rst Lib/imghdr.py Lib/test/imghdrdata/python.exr Lib/test/test_imghdr.py Misc/NEWS description: #20295: Teach imghdr to recognize OpenEXR format images. Patch by Martin Vignali, test by Claudiu Popa. diff -r 9f51e71bf761 -r 71b9a841119a Doc/library/imghdr.rst --- a/Doc/library/imghdr.rst Thu Jun 26 09:25:41 2014 -0700 +++ b/Doc/library/imghdr.rst Thu Jun 26 12:27:57 2014 -0400 @@ -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 -r 9f51e71bf761 -r 71b9a841119a Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst Thu Jun 26 09:25:41 2014 -0700 +++ b/Doc/whatsnew/3.5.rst Thu Jun 26 12:27:57 2014 -0400 @@ -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 `_ + format (contributed by Martin vignali and Cladui Popa in :issue:`20295`). + importlib --------- diff -r 9f51e71bf761 -r 71b9a841119a Lib/imghdr.py --- a/Lib/imghdr.py Thu Jun 26 09:25:41 2014 -0700 +++ b/Lib/imghdr.py Thu Jun 26 12:27:57 2014 -0400 @@ -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 -r 9f51e71bf761 -r 71b9a841119a Lib/test/imghdrdata/python.exr Binary file Lib/test/imghdrdata/python.exr has changed diff -r 9f51e71bf761 -r 71b9a841119a Lib/test/test_imghdr.py --- a/Lib/test/test_imghdr.py Thu Jun 26 09:25:41 2014 -0700 +++ b/Lib/test/test_imghdr.py Thu Jun 26 12:27:57 2014 -0400 @@ -18,6 +18,7 @@ ('python.tiff', 'tiff'), ('python.xbm', 'xbm'), ('python.webp', 'webp'), + ('python.exr', 'exr'), ) class UnseekableIO(io.FileIO): diff -r 9f51e71bf761 -r 71b9a841119a Misc/NEWS --- a/Misc/NEWS Thu Jun 26 09:25:41 2014 -0700 +++ b/Misc/NEWS Thu Jun 26 12:27:57 2014 -0400 @@ -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.