From dd2266d8a68a775da5fe0ab89b61b8be19180849 Mon Sep 17 00:00:00 2001 From: Hans-Peter Jansen Date: Thu, 5 Feb 2015 12:14:30 +0100 Subject: [PATCH 1/3] raise limits to skip webp alpha tests for libwebp <= 0.2.1 --- _webp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/_webp.c b/_webp.c index c201813d7..f9914d206 100644 --- a/_webp.c +++ b/_webp.c @@ -228,10 +228,14 @@ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){ /* * The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well. - * Files that are valid with 0.3 are reported as being invalid. + * Files that are valid with 0.3 are reported as being invalid. + * 0.2.1, that ships with openSUSE 12.3 fails consistently with: + * AssertionError: average pixel value difference 3.0000 > epsilon 1.0000 + * therefor, we're suppressing alpha channel tests for webp <= 0.2.1, and users of this + * part of the lib are being warned */ PyObject* WebPDecoderBuggyAlpha_wrapper(PyObject* self, PyObject* args){ - return Py_BuildValue("i", WebPGetDecoderVersion()==0x0103); + return Py_BuildValue("i", WebPGetDecoderVersion()<=0x0201); } static PyMethodDef webpMethods[] = From 0b252ed89d0a1486d80d3324cf619e3020f9cf55 Mon Sep 17 00:00:00 2001 From: Hans-Peter Jansen Date: Fri, 6 Feb 2015 08:55:12 +0100 Subject: [PATCH 2/3] Revert "raise limits to skip webp alpha tests for libwebp <= 0.2.1" This reverts commit dd2266d8a68a775da5fe0ab89b61b8be19180849. --- _webp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/_webp.c b/_webp.c index f9914d206..c201813d7 100644 --- a/_webp.c +++ b/_webp.c @@ -228,14 +228,10 @@ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){ /* * The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well. - * Files that are valid with 0.3 are reported as being invalid. - * 0.2.1, that ships with openSUSE 12.3 fails consistently with: - * AssertionError: average pixel value difference 3.0000 > epsilon 1.0000 - * therefor, we're suppressing alpha channel tests for webp <= 0.2.1, and users of this - * part of the lib are being warned + * Files that are valid with 0.3 are reported as being invalid. */ PyObject* WebPDecoderBuggyAlpha_wrapper(PyObject* self, PyObject* args){ - return Py_BuildValue("i", WebPGetDecoderVersion()<=0x0201); + return Py_BuildValue("i", WebPGetDecoderVersion()==0x0103); } static PyMethodDef webpMethods[] = From 9c76932d3363ef08d6755a6876e9c3725432fc3a Mon Sep 17 00:00:00 2001 From: Hans-Peter Jansen Date: Fri, 6 Feb 2015 09:04:23 +0100 Subject: [PATCH 3/3] early versions of webp are known to produce higher deviations: deal with it --- Tests/test_file_webp_alpha.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_webp_alpha.py b/Tests/test_file_webp_alpha.py index 22c5c0922..f316b71e1 100644 --- a/Tests/test_file_webp_alpha.py +++ b/Tests/test_file_webp_alpha.py @@ -83,7 +83,11 @@ class TestFileWebpAlpha(PillowTestCase): image.load() image.getdata() - self.assert_image_similar(image, pil_image, 1.0) + # early versions of webp are known to produce higher deviations: deal with it + if _webp.WebPDecoderVersion(self) <= 0x201: + self.assert_image_similar(image, pil_image, 3.0) + else: + self.assert_image_similar(image, pil_image, 1.0) if __name__ == '__main__':