]> granicus.if.org Git - python/commitdiff
Issue #20197: Added support for the WebP image type in the imghdr module.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 25 May 2014 08:45:37 +0000 (11:45 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 25 May 2014 08:45:37 +0000 (11:45 +0300)
Patch by Fabrice Aneche and Claudiu Popa.

Doc/library/imghdr.rst
Lib/imghdr.py
Lib/test/imghdrdata/python.webp [new file with mode: 0644]
Lib/test/test_imghdr.py
Misc/ACKS
Misc/NEWS

index 9e8952339ccae4d685dafed667ea104850b8be41..06faa883d3f89c5741908c3dd47ccf08abed9514 100644 (file)
@@ -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:
index add2ea8898395e8052d7d38fb860a68f38ba49ef..fe77e495fb6ae3d7d9ea962141399b6f798d3476 100644 (file)
@@ -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
new file mode 100644 (file)
index 0000000..e824ec7
Binary files /dev/null and b/Lib/test/imghdrdata/python.webp differ
index 0ad4343f520b1b0909e28fcbacd1e53ad1ce7c93..e2a1acab32288e639097e2bdedb89a5b0267adc3 100644 (file)
@@ -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):
index be089cd7166fd3c588f4d5274412396dd5fa35c4..68701c486e076f36e1583a53ce4d522bbc363719 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -42,6 +42,7 @@ Pehr Anderson
 Erik Andersén
 Oliver Andrich
 Ross Andrus
+Fabrice Aneche
 Juancarlo Añez
 Chris Angelico
 Jérémy Anger
index 72f00dc8c8db689a1bf6392dad1b59b9eafa9d9a..4970afdd766e544b8077920021b7f00d96af118c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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.