From 2f60820f4c1bdfce75f30ddc53d97587a3256dcf Mon Sep 17 00:00:00 2001 From: R David Murray Date: Thu, 26 Jun 2014 12:27:57 -0400 Subject: [PATCH] #20295: Teach imghdr to recognize OpenEXR format images. Patch by Martin Vignali, test by Claudiu Popa. --- Doc/library/imghdr.rst | 5 +++++ Doc/whatsnew/3.5.rst | 6 ++++++ Lib/imghdr.py | 6 ++++++ Lib/test/imghdrdata/python.exr | Bin 0 -> 2635 bytes Lib/test/test_imghdr.py | 1 + Misc/NEWS | 2 ++ 6 files changed, 20 insertions(+) create mode 100644 Lib/test/imghdrdata/python.exr diff --git a/Doc/library/imghdr.rst b/Doc/library/imghdr.rst index 06faa883d3..c60df24c5a 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 1b4253ce72..9fff48cf55 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 `_ + format (contributed by Martin vignali and Cladui Popa in :issue:`20295`). + importlib --------- diff --git a/Lib/imghdr.py b/Lib/imghdr.py index fe77e495fb..b26792539d 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 new file mode 100644 index 0000000000000000000000000000000000000000..773c81ee1fb850cdbb6cccd3ae5edabb80146481 GIT binary patch literal 2635 zcmcJROK2NM7{@2=N@|-p=|Qy*&7%~@59(Nt9qrD{DhX+Ai$Y5vmGPwyR7-LMiexOs zO(7|QBFmSQLUHU%A5d)h)E0`IT#^`yB17rp;>J*toManH+guzM3T?lco%Qb8Dm`_U z-I?7P&G(!C_n$$NfzZCk5JIEp6S-U}TYyG3Qz)XB;oBLs51zd6n%^((`4Zdn<=mbx zXf%Ied?HmSWb!#zTTGu!6cZzvTr&R-dOLq9oIy|Xh_W1ln%~JxVLY37_dmyFGr82+ ziDYU5*)0)eJaZ|PJyRG@jTX-(ikUo0XY+|7Qbe56>B8tlDwQ**e<_tK!UU7yGT>-%92u@w`Iw28!})*_a_yz24^?ozV2MpXdU;Ku^*wQX}p@{+1<} z944FkwBDgtw7vaJJdewG04sP}-3Z(LT!xbUicALU=?P8sIy(_srzm=b4$^1nJu=^d zBTi8C4}DIL>D$_D3ywNQ(KzEC-w6uNF&vqP)gg41WXS+HV-1|4>vshO=jbqgXJ0aejz_j|O*+FQksQ&7#*YR< z-0ngTv3@tj62*{B6wMpu;8C_tzo6V1ZNeE`jVN%`AlH0dm&q%nli1GSYIuQTo81*0 zo(NZiJ7ZBegHsG~f57|?frD?eRvgR565YZB;5vRSs*mU`IwhRZ6wa6t6miJ)MtC8F z(Cd&Br!y*oViG8>vrj>fRqS>~RZxt{y@?Rt-cF7sdPk5Kf&99*EXO7B_w*WlgPx!t zlQ@Q-h{9LrQx`(XAS{a`E}J8F834afDjY<3RnWqx-U*e1eC7kf8IzESL&jM{ zH;x&9vj>vmP2fn1GlOSv&W>&}h`jLQjC0&(JnB;9lNNq$XMTK9IHQKQVJDar7&>V*RY0J)-yFx(5`FA~<58 znssSF0eOYH1h?{Bxu@O-bGmr_xEh`cO$Y4Loog|GW2!ei4_d$vcNN