From b21ad9cf46440b5e0e0b3f0a211f1c233464e325 Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Thu, 9 Aug 2018 14:44:56 +0900 Subject: [PATCH 1/4] Issue #1942 - Upgrades pillow version to 5.2.0 --- config/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/requirements.txt b/config/requirements.txt index bf3573b93..df1bea667 100644 --- a/config/requirements.txt +++ b/config/requirements.txt @@ -7,7 +7,7 @@ GitHub-Flask==3.1.5 mock==2.0.0 nose==1.3.7 pep8==1.7.0 -Pillow==4.0.0 +Pillow==5.2.0 requests==2.13.0 ua-parser==0.8 WTForms==2.1 From 3976e78ffebbcaf0bbf3989b4022aad63304b2c2 Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Thu, 9 Aug 2018 14:46:57 +0900 Subject: [PATCH 2/4] Issue #1942 - Converts PNG images to RGB to remove the Alpha channel This was deprecated in 4.2.0 https://github.com/python-pillow/Pillow/blob/master/docs/releasenotes/4.2.0.rst#removed-deprecated-items and as we upgrade to 5.2.0, we need to take care of this case. see the discussion in https://github.com/python-pillow/Pillow/issues/2609 --- webcompat/api/uploads.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webcompat/api/uploads.py b/webcompat/api/uploads.py index 8b06c8445..2ac8c7238 100644 --- a/webcompat/api/uploads.py +++ b/webcompat/api/uploads.py @@ -104,6 +104,9 @@ def save(self): dest_dir = os.path.dirname(file_dest) if not os.path.exists(dest_dir): os.makedirs(dest_dir) + # Alpha channels are not supported in JPEG + if (self.image_object.format == 'PNG'): + self.image_object = self.image_object.convert('RGB') # Optimize further the image compression for these formats if self.image_object.format in ['JPEG', 'JPG', 'JPE', 'PNG']: save_parameters['optimize'] = True From 26a4341cbb1b75d16eaa8544ab07d3956b6736ff Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Thu, 9 Aug 2018 14:48:32 +0900 Subject: [PATCH 3/4] Issue #1942 - Changes the thumbnail size to 1024px --- webcompat/api/uploads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webcompat/api/uploads.py b/webcompat/api/uploads.py index 2ac8c7238..90466f92e 100644 --- a/webcompat/api/uploads.py +++ b/webcompat/api/uploads.py @@ -119,7 +119,7 @@ def save(self): # unpacking save_parameters self.image_object.save(file_dest, **save_parameters) # Creating the thumbnail - size = (700, 700) + size = (1024, 1024) self.image_object.thumbnail(size, Image.BILINEAR) self.image_object.save(thumb_dest, **save_parameters) From f8e3e3acdd643e17707842e13279418f0dffdcd8 Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Thu, 9 Aug 2018 15:10:37 +0900 Subject: [PATCH 4/4] Issue #1942 - Changes Pillow save filter to HAMMING --- webcompat/api/uploads.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webcompat/api/uploads.py b/webcompat/api/uploads.py index 90466f92e..09222cc9e 100644 --- a/webcompat/api/uploads.py +++ b/webcompat/api/uploads.py @@ -120,7 +120,7 @@ def save(self): self.image_object.save(file_dest, **save_parameters) # Creating the thumbnail size = (1024, 1024) - self.image_object.thumbnail(size, Image.BILINEAR) + self.image_object.thumbnail(size, Image.HAMMING) self.image_object.save(thumb_dest, **save_parameters)