diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de7b951..b7d5a4be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Index ePub documents for full-text search, with a new `get_epub_index_data` helper and automatic indexing of ePub items, like PDFs already are (#333) +### Removed + +- **BREAKING** Remove deprecated `convert` parameter from `optimize_image` (use `dst_format` instead) (#292) + ### Fixed - Carry a script's top-level `const`, `let` and `class` declarations across the wombat block, so other scripts on the page can still see them (#329) diff --git a/src/zimscraperlib/image/optimization.py b/src/zimscraperlib/image/optimization.py index 5f9c7d09..abf8d2bd 100644 --- a/src/zimscraperlib/image/optimization.py +++ b/src/zimscraperlib/image/optimization.py @@ -23,7 +23,6 @@ import pathlib import subprocess import tempfile -import warnings from dataclasses import dataclass import piexif # pyright: ignore[reportMissingTypeStubs] @@ -407,7 +406,6 @@ def optimize_image( *, dst_format: str | None = None, delete_src: bool = False, - convert: bool | str = False, ) -> pathlib.Path | io.BytesIO: """Optimize image, automatically selecting correct optimizer @@ -415,22 +413,7 @@ def optimize_image( dst_format: format of the destination image, required when dst is io.BytesIO. delete_src: whether to remove src file upon success (boolean) - values: True | False - convert: will be deprecated in scraperlib 6, use dst_format instead. - values: False: don't convert - True: convert to format implied by dst suffix - str: convert to the specified format""" - - if convert is not False: - warnings.warn( - "The 'convert' param is deprecated and will be removed in scraperlib 6." - "Use 'dst_format' parameter instead.", - DeprecationWarning, - stacklevel=2, - ) - - if isinstance(convert, str): - dst_format = convert + values: True | False""" if options is None: options = OptimizeOptions.of() diff --git a/tests/image/test_image.py b/tests/image/test_image.py index 98fd03cb..5037c86d 100644 --- a/tests/image/test_image.py +++ b/tests/image/test_image.py @@ -633,24 +633,22 @@ def test_optimize_image_delete_src_not_applicable_for_bytes(): optimize_image(src, dst, dst_format="png", delete_src=True) -def test_optimize_image_deprecated_convert_str(png_image: pathlib.Path): +def test_optimize_image_convert_format_bytesio(png_image: pathlib.Path): src = png_image dst = io.BytesIO() - with pytest.warns(DeprecationWarning, match="The 'convert' param is deprecated"): - optimize_image(src, dst, convert="jpg") + optimize_image(src, dst, dst_format="jpg") dst.seek(0) assert Image.open(dst).format == "JPEG" -def test_optimize_image_deprecated_convert_true( +def test_optimize_image_convert_format_path( png_image: pathlib.Path, tmp_path: pathlib.Path ): src = png_image dst = tmp_path / "out.jpg" - with pytest.warns(DeprecationWarning, match="The 'convert' param is deprecated"): - optimize_image(src, dst, convert=True) + optimize_image(src, dst) assert dst.exists() assert Image.open(dst).format == "JPEG"