#20295: Teach imghdr to recognize OpenEXR format images.

Patch by Martin Vignali, test by Claudiu Popa.
This commit is contained in:
R David Murray 2014-06-26 12:27:57 -04:00
parent a157867a3d
commit 2f60820f4c
6 changed files with 20 additions and 0 deletions

View 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.

View 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
---------

View 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 #
#--------------------#

Binary file not shown.

View File

@ -18,6 +18,7 @@ TEST_FILES = (
('python.tiff', 'tiff'),
('python.xbm', 'xbm'),
('python.webp', 'webp'),
('python.exr', 'exr'),
)
class UnseekableIO(io.FileIO):

View File

@ -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.