diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-05-25 08:45:37 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-05-25 08:45:37 (GMT) |
commit | 2f8dca735e9e30aab6cea2270875021b3098bd2a (patch) | |
tree | 74cf9e463b935a6d961cf5d7948d293221fb4454 | |
parent | e84d26c61b826792f62d49cda64f1f8c76dcf55c (diff) | |
download | cpython-2f8dca735e9e30aab6cea2270875021b3098bd2a.zip cpython-2f8dca735e9e30aab6cea2270875021b3098bd2a.tar.gz cpython-2f8dca735e9e30aab6cea2270875021b3098bd2a.tar.bz2 |
Issue #20197: Added support for the WebP image type in the imghdr module.
Patch by Fabrice Aneche and Claudiu Popa.
-rw-r--r-- | Doc/library/imghdr.rst | 5 | ||||
-rw-r--r-- | Lib/imghdr.py | 6 | ||||
-rw-r--r-- | Lib/test/imghdrdata/python.webp | bin | 0 -> 432 bytes | |||
-rw-r--r-- | Lib/test/test_imghdr.py | 3 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
6 files changed, 17 insertions, 1 deletions
diff --git a/Doc/library/imghdr.rst b/Doc/library/imghdr.rst index 9e89523..06faa88 100644 --- a/Doc/library/imghdr.rst +++ b/Doc/library/imghdr.rst @@ -48,6 +48,11 @@ from :func:`what`: +------------+-----------------------------------+ | ``'png'`` | Portable Network Graphics | +------------+-----------------------------------+ +| ``'webp'`` | WebP files | ++------------+-----------------------------------+ + +.. versionchanged:: 3.5 + The *webp* type was added. You can extend the list of file types :mod:`imghdr` can recognize by appending to this variable: diff --git a/Lib/imghdr.py b/Lib/imghdr.py index add2ea8..fe77e49 100644 --- a/Lib/imghdr.py +++ b/Lib/imghdr.py @@ -110,6 +110,12 @@ def test_bmp(h, f): tests.append(test_bmp) +def test_webp(h, f): + if h.startswith(b'RIFF') and h[8:12] == b'WEBP': + return 'webp' + +tests.append(test_webp) + #--------------------# # Small test program # #--------------------# diff --git a/Lib/test/imghdrdata/python.webp b/Lib/test/imghdrdata/python.webp Binary files differnew file mode 100644 index 0000000..e824ec7 --- /dev/null +++ b/Lib/test/imghdrdata/python.webp diff --git a/Lib/test/test_imghdr.py b/Lib/test/test_imghdr.py index 0ad4343..e2a1aca 100644 --- a/Lib/test/test_imghdr.py +++ b/Lib/test/test_imghdr.py @@ -16,7 +16,8 @@ TEST_FILES = ( ('python.ras', 'rast'), ('python.sgi', 'rgb'), ('python.tiff', 'tiff'), - ('python.xbm', 'xbm') + ('python.xbm', 'xbm'), + ('python.webp', 'webp'), ) class UnseekableIO(io.FileIO): @@ -42,6 +42,7 @@ Pehr Anderson Erik Andersén Oliver Andrich Ross Andrus +Fabrice Aneche Juancarlo Añez Chris Angelico Jérémy Anger @@ -89,6 +89,9 @@ Core and Builtins Library ------- +- Issue #20197: Added support for the WebP image type in the imghdr module. + Patch by Fabrice Aneche and Claudiu Popa. + - Issue #21513: Speedup some properties of IP addresses (IPv4Address, IPv6Address) such as .is_private or .is_multicast. |