Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion Tests/test_shell_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------

Expand Down
10 changes: 7 additions & 3 deletions docs/releasenotes/13.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
===========
Expand Down
6 changes: 6 additions & 0 deletions src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down