diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 0e16d867a3b..07f136821fe 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -734,7 +734,8 @@ def test_restart_markers(self, blocks: int, rows: int, markers: int) -> None: def test_load_djpeg(self) -> None: with Image.open(TEST_FILE) as img: assert isinstance(img, JpegImagePlugin.JpegImageFile) - img.load_djpeg() + with pytest.warns(DeprecationWarning, match="load_djpeg"): + img.load_djpeg() assert_image_similar_tofile(img, TEST_FILE, 5) def test_no_duplicate_0x1001_tag(self) -> None: diff --git a/Tests/test_shell_injection.py b/Tests/test_shell_injection.py index a7e95ed83c8..bd7b2cecb0f 100644 --- a/Tests/test_shell_injection.py +++ b/Tests/test_shell_injection.py @@ -44,7 +44,8 @@ def test_load_djpeg_filename(self, tmp_path: Path) -> None: with Image.open(src_file) as im: assert isinstance(im, JpegImagePlugin.JpegImageFile) - im.load_djpeg() + with pytest.warns(DeprecationWarning, match="load_djpeg"): + im.load_djpeg() @pytest.mark.skipif(not netpbm_available(), reason="Netpbm not available") def test_save_netpbm_filename_bmp_mode(self, tmp_path: Path) -> None: diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 70745104483..6ee46a0a76a 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -30,6 +30,18 @@ Image getdata() identical, except that it returns a tuple of pixel values, instead of an internal Pillow data type. + +JpegImageFile.load_djpeg +~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 13.0.0 + +``JpegImageFile.load_djpeg`` has been deprecated, and will be removed in Pillow 14 +(2027-10-15). + +Use the built-in JPEG decoder instead, or call ``djpeg`` directly and decode the +resulting image with Pillow. + Removed features ---------------- diff --git a/docs/releasenotes/13.0.0.rst b/docs/releasenotes/13.0.0.rst index 45667d9ec07..a04828a87ea 100644 --- a/docs/releasenotes/13.0.0.rst +++ b/docs/releasenotes/13.0.0.rst @@ -69,10 +69,14 @@ ImageCms.ImageCmsProfile.product_name and .product_info Deprecations ============ -TODO -^^^^ +JpegImageFile.load_djpeg +^^^^^^^^^^^^^^^^^^^^^^^^ -TODO +``JpegImageFile.load_djpeg`` has been deprecated, and will be removed in Pillow 14 +(2027-10-15). + +Use the built-in JPEG decoder instead, or call ``djpeg`` directly and decode the +resulting image with Pillow. API changes =========== diff --git a/src/PIL/JpegImagePlugin.py b/src/PIL/JpegImagePlugin.py index 5d4347818d4..3d89951319e 100644 --- a/src/PIL/JpegImagePlugin.py +++ b/src/PIL/JpegImagePlugin.py @@ -48,6 +48,7 @@ from ._binary import i32be as i32 from ._binary import o8 from ._binary import o16be as o16 +from ._deprecate import deprecate from .JpegPresets import presets TYPE_CHECKING = False @@ -467,6 +468,11 @@ def draft( def load_djpeg(self) -> None: # ALTERNATIVE: handle JPEGs via the IJG command line utilities + deprecate( + "load_djpeg", + 14, + action="Use the built-in JPEG decoder instead, or call djpeg yourself.", + ) f, path = tempfile.mkstemp() os.close(f)