changeset: 90820:4fd17e28d4bf user: Serhiy Storchaka date: Sun May 25 11:45:37 2014 +0300 files: Doc/library/imghdr.rst Lib/imghdr.py Lib/test/imghdrdata/python.webp Lib/test/test_imghdr.py Misc/ACKS Misc/NEWS description: Issue #20197: Added support for the WebP image type in the imghdr module. Patch by Fabrice Aneche and Claudiu Popa. diff -r eb86a3c81dbb -r 4fd17e28d4bf Doc/library/imghdr.rst --- a/Doc/library/imghdr.rst Sat May 24 18:48:45 2014 -0400 +++ b/Doc/library/imghdr.rst Sun May 25 11:45:37 2014 +0300 @@ -48,6 +48,11 @@ +------------+-----------------------------------+ | ``'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 -r eb86a3c81dbb -r 4fd17e28d4bf Lib/imghdr.py --- a/Lib/imghdr.py Sat May 24 18:48:45 2014 -0400 +++ b/Lib/imghdr.py Sun May 25 11:45:37 2014 +0300 @@ -110,6 +110,12 @@ 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 -r eb86a3c81dbb -r 4fd17e28d4bf Lib/test/imghdrdata/python.webp Binary file Lib/test/imghdrdata/python.webp has changed diff -r eb86a3c81dbb -r 4fd17e28d4bf Lib/test/test_imghdr.py --- a/Lib/test/test_imghdr.py Sat May 24 18:48:45 2014 -0400 +++ b/Lib/test/test_imghdr.py Sun May 25 11:45:37 2014 +0300 @@ -16,7 +16,8 @@ ('python.ras', 'rast'), ('python.sgi', 'rgb'), ('python.tiff', 'tiff'), - ('python.xbm', 'xbm') + ('python.xbm', 'xbm'), + ('python.webp', 'webp'), ) class UnseekableIO(io.FileIO): diff -r eb86a3c81dbb -r 4fd17e28d4bf Misc/ACKS --- a/Misc/ACKS Sat May 24 18:48:45 2014 -0400 +++ b/Misc/ACKS Sun May 25 11:45:37 2014 +0300 @@ -42,6 +42,7 @@ Erik Andersén Oliver Andrich Ross Andrus +Fabrice Aneche Juancarlo Añez Chris Angelico Jérémy Anger diff -r eb86a3c81dbb -r 4fd17e28d4bf Misc/NEWS --- a/Misc/NEWS Sat May 24 18:48:45 2014 -0400 +++ b/Misc/NEWS Sun May 25 11:45:37 2014 +0300 @@ -89,6 +89,9 @@ 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.