diff --git a/requirements-production.txt b/requirements-production.txt index 042c1fd3..8d2e0361 100644 --- a/requirements-production.txt +++ b/requirements-production.txt @@ -2,7 +2,7 @@ beautifulsoup4>=4.9.3,<5 bleach>=3.2,<3.3 Django>=4.0,<4.1 Markdown>=3.0,<4 -Pillow>=8.0,<9 +Pillow>=9.3,<10 boto3>=1.14,<1.15 celery>=5.2,<5.3 django-compressor>=3,<4 diff --git a/requirements.txt b/requirements.txt index 38eb338e..5451bd22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ bleach>=3.2,<3.3 Django>=4.0,<4.1 Fabric>=2.5,<2.6 Markdown>=3.0,<4 -Pillow>=8.0,<9 +Pillow>=9.3,<10 boto3>=1.14,<1.15 celery>=5.2,<5.3 django-compressor>=3,<4 diff --git a/screenshots/models.py b/screenshots/models.py index cdb3093b..ee667ef7 100644 --- a/screenshots/models.py +++ b/screenshots/models.py @@ -79,9 +79,7 @@ def create_original(self): def create_thumbnail(self, target_size): img = self.image - - if img.format == 'JPEG': - img = ImageOps.exif_transpose(img) + img = ImageOps.exif_transpose(img) crop_params, resize_params = get_thumbnail_sizing_params(img.size, target_size) if crop_params: @@ -96,15 +94,15 @@ def create_thumbnail(self, target_size): # must ensure image is non-paletted for a high-quality resize if img.mode in ['1', 'P']: img = img.convert('RGB') - img = img.resize(resize_params, Image.ANTIALIAS) + img = img.resize(resize_params, Image.Resampling.LANCZOS) output = io.BytesIO() if has_limited_palette: if img.mode not in ['1', 'P']: - # img.convert with palette=Image.ADAPTIVE will apparently only work on + # img.convert with palette=Image.Palette.ADAPTIVE will apparently only work on # 'L' or 'RGB' images, not RGBA for example. So, need to pre-convert to RGB... img = img.convert('RGB') - img = img.convert('P', palette=Image.ADAPTIVE, colors=256) + img = img.convert('P', palette=Image.Palette.ADAPTIVE, colors=256) img.save(output, format='PNG', optimize=True) return output, img.size, 'png' else: diff --git a/screenshots/tests/images/bfield-standard.out.jpg b/screenshots/tests/images/bfield-standard.out.jpg index 3d4d354f..9a5a6cc1 100644 Binary files a/screenshots/tests/images/bfield-standard.out.jpg and b/screenshots/tests/images/bfield-standard.out.jpg differ diff --git a/screenshots/tests/images/twintris.out.jpg b/screenshots/tests/images/twintris.out.jpg index 518cb0dc..0bca5f05 100644 Binary files a/screenshots/tests/images/twintris.out.jpg and b/screenshots/tests/images/twintris.out.jpg differ diff --git a/screenshots/tests/test_conversion.py b/screenshots/tests/test_conversion.py index d2d4415f..7f807d4a 100644 --- a/screenshots/tests/test_conversion.py +++ b/screenshots/tests/test_conversion.py @@ -21,7 +21,7 @@ def assertImagesSimilar(self, img1, img2): sum_squares = sum(sq) result = math.sqrt(sum_squares / float(image1.size[0] * image1.size[1])) - self.assertTrue(result < 1, "Images are too different") + self.assertTrue(result < 5, "Images are too different") def test_wmf(self): # WMF is not in our PIL_READABLE_FORMATS list