Skip to content

Commit

Permalink
[fc] Repository: plone.scale
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2023-10-17T16:57:16+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@0654c36

feat: avoid to convert webp to jpeg

Files changed:
M plone/scale/scale.py
M plone/scale/tests/test_scale.py
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-17T17:03:14+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@effc3cd

changelog

Files changed:
A news/85.feature
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-17T17:04:32+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@c98fb4d

test: missing webp image for tests

Files changed:
A plone/scale/tests/data/profile.webp
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-17T17:34:26+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@04b0642

Update plone/scale/tests/test_scale.py

Co-authored-by: Piero Nicolli &lt;[email protected]&gt;

Files changed:
M plone/scale/tests/test_scale.py
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-17T17:43:34+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@b0fa647

comments

Files changed:
M plone/scale/scale.py
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-18T09:31:31+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: plone/plone.scale@60e4f9a

Update news/85.feature

Co-authored-by: David Glick &lt;[email protected]&gt;

Files changed:
M news/85.feature
Repository: plone.scale

Branch: refs/heads/master
Date: 2023-10-18T11:01:21-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/plone.scale@767534d

Merge pull request #85 from plone/webp

feat: avoid to convert webp to jpeg

Files changed:
A news/85.feature
A plone/scale/tests/data/profile.webp
M plone/scale/scale.py
M plone/scale/tests/test_scale.py
  • Loading branch information
davisagli committed Oct 18, 2023
1 parent 44b2fdf commit d7d6e3c
Showing 1 changed file with 97 additions and 22 deletions.
119 changes: 97 additions & 22 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,115 @@
Repository: plone.app.registry
Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-17T22:56:39+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.registry/commit/5dd4e9d72ee995a71aa1d5a35ecc7a3e65dd0faf
Date: 2023-10-17T16:57:16+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/0654c36a28a353158a0816f21b0abfce5a90b71c

Require setuptools 68.2+ for building the package.
feat: avoid to convert webp to jpeg

Configuring with plone/meta
Files changed:
M plone/scale/scale.py
M plone/scale/tests/test_scale.py

b'diff --git a/plone/scale/scale.py b/plone/scale/scale.py\nindex 77f2592..3c3953b 100644\n--- a/plone/scale/scale.py\n+++ b/plone/scale/scale.py\n@@ -112,7 +112,7 @@ def scaleImage(\n \n else:\n # All other formats only process a single frame\n- if format_ not in ("PNG", "GIF"):\n+ if format_ not in ("PNG", "GIF", "WEBP"):\n # Always generate JPEG, except if format is PNG or GIF.\n format_ = "JPEG"\n image, format_ = scaleSingleFrame(\ndiff --git a/plone/scale/tests/test_scale.py b/plone/scale/tests/test_scale.py\nindex 1f75d48..e48dfac 100644\n--- a/plone/scale/tests/test_scale.py\n+++ b/plone/scale/tests/test_scale.py\n@@ -22,6 +22,8 @@\n CMYK = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "profile.jpg"), "rb") as fio:\n PROFILE = fio.read()\n+with open(os.path.join(TEST_DATA_LOCATION, "profile.webp"), "rb") as fio:\n+ PROFILE_WEBP = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "animated.gif"), "rb") as fio:\n ANIGIF = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "animated2.gif"), "rb") as fio:\n@@ -90,6 +92,15 @@ def testScaleWithFewColorsStaysColored(self):\n self.assertEqual(image.mode, "RGB")\n self.assertEqual(image.format, "JPEG")\n \n+ def testScaledWeb(self):\n+ (imagedata, format, size) = scaleImage(PROFILE_WEBP, 120, 120)\n+ self.assertEqual(format, "WEBP")\n+ self.assertEqual(size, (120, 120))\n+ self.assertTrue(len(imagedata) < len(PROFILE_WEBP))\n+ input = StringIO(imagedata)\n+ image = PIL.Image.open(input)\n+ self.assertIsNotNone(image.info.get("icc_profile"))\n+\n def testAutomaticGreyscale(self):\n src = PIL.Image.new("RGB", (256, 256), (255, 255, 255))\n draw = PIL.ImageDraw.Draw(src)\n'

Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-17T17:03:14+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/effc3cdd856dbfb70f3182df43a000e71b704740

changelog

Files changed:
A news/85.feature

b'diff --git a/news/85.feature b/news/85.feature\nnew file mode 100644\nindex 0000000..3a3daf2\n--- /dev/null\n+++ b/news/85.feature\n@@ -0,0 +1 @@\n+avoid to convert webp to jpeg @mamico\n'

Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-17T17:04:32+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/c98fb4d213125beebb0563cd84a507cccebd8d7b

test: missing webp image for tests

Files changed:
A plone/scale/tests/data/profile.webp

b'diff --git a/plone/scale/tests/data/profile.webp b/plone/scale/tests/data/profile.webp\nnew file mode 100644\nindex 0000000..2d0b9b0\nBinary files /dev/null and b/plone/scale/tests/data/profile.webp differ\n'

Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-17T17:34:26+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/04b06420ea1c9ea6ba7e96774cf58d9035969dbf

Update plone/scale/tests/test_scale.py

Co-authored-by: Piero Nicolli &lt;[email protected]&gt;

Files changed:
M plone/scale/tests/test_scale.py

b'diff --git a/plone/scale/tests/test_scale.py b/plone/scale/tests/test_scale.py\nindex e48dfac..58baed9 100644\n--- a/plone/scale/tests/test_scale.py\n+++ b/plone/scale/tests/test_scale.py\n@@ -92,7 +92,7 @@ def testScaleWithFewColorsStaysColored(self):\n self.assertEqual(image.mode, "RGB")\n self.assertEqual(image.format, "JPEG")\n \n- def testScaledWeb(self):\n+ def testScaledWebp(self):\n (imagedata, format, size) = scaleImage(PROFILE_WEBP, 120, 120)\n self.assertEqual(format, "WEBP")\n self.assertEqual(size, (120, 120))\n'

Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-17T17:43:34+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/b0fa6476b44b2c25abcf18bd56ce0f017e89bf71

comments

Files changed:
M plone/scale/scale.py

b'diff --git a/plone/scale/scale.py b/plone/scale/scale.py\nindex 3c3953b..01ba778 100644\n--- a/plone/scale/scale.py\n+++ b/plone/scale/scale.py\n@@ -67,8 +67,8 @@ def scaleImage(\n The `width`, `height`, `mode` parameters will be passed to\n :meth:`scalePILImage`, which performs the actual scaling.\n \n- The generated image is a JPEG image, unless the original is a PNG or GIF\n- image. This is needed to make sure alpha channel information is\n+ The generated image is a JPEG image, unless the original is a WEBP, PNG\n+ or GIF image. This is needed to make sure alpha channel information is\n not lost, which JPEG does not support.\n """\n if isinstance(image, (bytes, str)):\n@@ -113,7 +113,7 @@ def scaleImage(\n else:\n # All other formats only process a single frame\n if format_ not in ("PNG", "GIF", "WEBP"):\n- # Always generate JPEG, except if format is PNG or GIF.\n+ # Always generate JPEG, except if format is WEBP, PNG or GIF.\n format_ = "JPEG"\n image, format_ = scaleSingleFrame(\n img,\n'

Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-18T09:31:31+02:00
Author: Mauro Amico (mamico) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/60e4f9a7cac148e5bdb078c7cbf35d8170b3a440

Update news/85.feature

Co-authored-by: David Glick &lt;[email protected]&gt;

Files changed:
A news/18d04723.internal
M .meta.toml
M pyproject.toml
M tox.ini
M news/85.feature

b'diff --git a/.meta.toml b/.meta.toml\nindex 24a698f..dd48f43 100644\n--- a/.meta.toml\n+++ b/.meta.toml\n@@ -3,4 +3,4 @@\n # See the inline comments on how to expand/tweak this configuration file\n [meta]\n template = "default"\n-commit-id = "68cda6e4"\n+commit-id = "e9621627"\ndiff --git a/news/18d04723.internal b/news/18d04723.internal\nnew file mode 100644\nindex 0000000..8497643\n--- /dev/null\n+++ b/news/18d04723.internal\n@@ -0,0 +1,2 @@\n+Require ``setuptools`` 68.2+ for building the package.\n+[plone devs]\ndiff --git a/pyproject.toml b/pyproject.toml\nindex 008afba..288d08c 100644\n--- a/pyproject.toml\n+++ b/pyproject.toml\n@@ -1,6 +1,9 @@\n # Generated from:\n # https://github.com/plone/meta/tree/master/config/default\n # See the inline comments on how to expand/tweak this configuration file\n+[build-system]\n+requires = ["setuptools>=68.2"]\n+\n [tool.towncrier]\n directory = "news/"\n filename = "CHANGES.rst"\ndiff --git a/tox.ini b/tox.ini\nindex 0924e16..076efb6 100644\n--- a/tox.ini\n+++ b/tox.ini\n@@ -65,7 +65,7 @@ deps =\n build\n z3c.dependencychecker==2.11\n commands =\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n dependencychecker\n \n [testenv:dependencies-graph]\n@@ -167,7 +167,7 @@ commands =\n # we build the change log as news entries might break\n # the README that is displayed on PyPI\n towncrier build --version=100.0.0 --yes\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n twine check dist/*\n \n [testenv:circular]\n'
b'diff --git a/news/85.feature b/news/85.feature\nindex 3a3daf2..fc77f79 100644\n--- a/news/85.feature\n+++ b/news/85.feature\n@@ -1 +1 @@\n-avoid to convert webp to jpeg @mamico\n+Keep scaled WEBP images in WEBP format instead of converting to JPEG. @mamico\n'

Repository: plone.app.registry
Repository: plone.scale


Branch: refs/heads/master
Date: 2023-10-18T14:58:45+02:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/plone.app.registry/commit/5e75a87d90dc731484c547a6a4967d0b0ef72354
Date: 2023-10-18T11:01:21-07:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/plone.scale/commit/767534d4acd915b66126d3e289a583bd29b2500a

Merge pull request #74 from plone/config-with-default-template-18d04723
Merge pull request #85 from plone/webp

Require setuptools 68.2+ for building the package.
feat: avoid to convert webp to jpeg

Files changed:
A news/18d04723.internal
M .meta.toml
M pyproject.toml
M tox.ini
A news/85.feature
A plone/scale/tests/data/profile.webp
M plone/scale/scale.py
M plone/scale/tests/test_scale.py

b'diff --git a/.meta.toml b/.meta.toml\nindex 24a698f..dd48f43 100644\n--- a/.meta.toml\n+++ b/.meta.toml\n@@ -3,4 +3,4 @@\n # See the inline comments on how to expand/tweak this configuration file\n [meta]\n template = "default"\n-commit-id = "68cda6e4"\n+commit-id = "e9621627"\ndiff --git a/news/18d04723.internal b/news/18d04723.internal\nnew file mode 100644\nindex 0000000..8497643\n--- /dev/null\n+++ b/news/18d04723.internal\n@@ -0,0 +1,2 @@\n+Require ``setuptools`` 68.2+ for building the package.\n+[plone devs]\ndiff --git a/pyproject.toml b/pyproject.toml\nindex 008afba..288d08c 100644\n--- a/pyproject.toml\n+++ b/pyproject.toml\n@@ -1,6 +1,9 @@\n # Generated from:\n # https://github.com/plone/meta/tree/master/config/default\n # See the inline comments on how to expand/tweak this configuration file\n+[build-system]\n+requires = ["setuptools>=68.2"]\n+\n [tool.towncrier]\n directory = "news/"\n filename = "CHANGES.rst"\ndiff --git a/tox.ini b/tox.ini\nindex 0924e16..076efb6 100644\n--- a/tox.ini\n+++ b/tox.ini\n@@ -65,7 +65,7 @@ deps =\n build\n z3c.dependencychecker==2.11\n commands =\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n dependencychecker\n \n [testenv:dependencies-graph]\n@@ -167,7 +167,7 @@ commands =\n # we build the change log as news entries might break\n # the README that is displayed on PyPI\n towncrier build --version=100.0.0 --yes\n- python -m build --sdist --no-isolation\n+ python -m build --sdist\n twine check dist/*\n \n [testenv:circular]\n'
b'diff --git a/news/85.feature b/news/85.feature\nnew file mode 100644\nindex 0000000..fc77f79\n--- /dev/null\n+++ b/news/85.feature\n@@ -0,0 +1 @@\n+Keep scaled WEBP images in WEBP format instead of converting to JPEG. @mamico\ndiff --git a/plone/scale/scale.py b/plone/scale/scale.py\nindex 77f2592..01ba778 100644\n--- a/plone/scale/scale.py\n+++ b/plone/scale/scale.py\n@@ -67,8 +67,8 @@ def scaleImage(\n The `width`, `height`, `mode` parameters will be passed to\n :meth:`scalePILImage`, which performs the actual scaling.\n \n- The generated image is a JPEG image, unless the original is a PNG or GIF\n- image. This is needed to make sure alpha channel information is\n+ The generated image is a JPEG image, unless the original is a WEBP, PNG\n+ or GIF image. This is needed to make sure alpha channel information is\n not lost, which JPEG does not support.\n """\n if isinstance(image, (bytes, str)):\n@@ -112,8 +112,8 @@ def scaleImage(\n \n else:\n # All other formats only process a single frame\n- if format_ not in ("PNG", "GIF"):\n- # Always generate JPEG, except if format is PNG or GIF.\n+ if format_ not in ("PNG", "GIF", "WEBP"):\n+ # Always generate JPEG, except if format is WEBP, PNG or GIF.\n format_ = "JPEG"\n image, format_ = scaleSingleFrame(\n img,\ndiff --git a/plone/scale/tests/data/profile.webp b/plone/scale/tests/data/profile.webp\nnew file mode 100644\nindex 0000000..2d0b9b0\nBinary files /dev/null and b/plone/scale/tests/data/profile.webp differ\ndiff --git a/plone/scale/tests/test_scale.py b/plone/scale/tests/test_scale.py\nindex 1f75d48..58baed9 100644\n--- a/plone/scale/tests/test_scale.py\n+++ b/plone/scale/tests/test_scale.py\n@@ -22,6 +22,8 @@\n CMYK = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "profile.jpg"), "rb") as fio:\n PROFILE = fio.read()\n+with open(os.path.join(TEST_DATA_LOCATION, "profile.webp"), "rb") as fio:\n+ PROFILE_WEBP = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "animated.gif"), "rb") as fio:\n ANIGIF = fio.read()\n with open(os.path.join(TEST_DATA_LOCATION, "animated2.gif"), "rb") as fio:\n@@ -90,6 +92,15 @@ def testScaleWithFewColorsStaysColored(self):\n self.assertEqual(image.mode, "RGB")\n self.assertEqual(image.format, "JPEG")\n \n+ def testScaledWebp(self):\n+ (imagedata, format, size) = scaleImage(PROFILE_WEBP, 120, 120)\n+ self.assertEqual(format, "WEBP")\n+ self.assertEqual(size, (120, 120))\n+ self.assertTrue(len(imagedata) < len(PROFILE_WEBP))\n+ input = StringIO(imagedata)\n+ image = PIL.Image.open(input)\n+ self.assertIsNotNone(image.info.get("icc_profile"))\n+\n def testAutomaticGreyscale(self):\n src = PIL.Image.new("RGB", (256, 256), (255, 255, 255))\n draw = PIL.ImageDraw.Draw(src)\n'

0 comments on commit d7d6e3c

Please sign in to comment.