Skip to content

Commit 7b1ba29

Browse files
authored
Remove unused _save_cjpeg (#9084)
2 parents 3c4fe62 + 50dde1c commit 7b1ba29

File tree

5 files changed

+3
-38
lines changed

5 files changed

+3
-38
lines changed

Tests/helper.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,6 @@ def djpeg_available() -> bool:
291291
return False
292292

293293

294-
def cjpeg_available() -> bool:
295-
if shutil.which("cjpeg"):
296-
try:
297-
subprocess.check_call(["cjpeg", "-version"])
298-
return True
299-
except subprocess.CalledProcessError: # pragma: no cover
300-
return False
301-
return False
302-
303-
304294
def netpbm_available() -> bool:
305295
return bool(shutil.which("ppmquant") and shutil.which("ppmtogif"))
306296

Tests/test_file_jpeg.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
assert_image_equal_tofile,
2727
assert_image_similar,
2828
assert_image_similar_tofile,
29-
cjpeg_available,
3029
djpeg_available,
3130
hopper,
3231
is_win32,
@@ -731,14 +730,6 @@ def test_load_djpeg(self) -> None:
731730
img.load_djpeg()
732731
assert_image_similar_tofile(img, TEST_FILE, 5)
733732

734-
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
735-
def test_save_cjpeg(self, tmp_path: Path) -> None:
736-
with Image.open(TEST_FILE) as img:
737-
tempfile = str(tmp_path / "temp.jpg")
738-
JpegImagePlugin._save_cjpeg(img, BytesIO(), tempfile)
739-
# Default save quality is 75%, so a tiny bit of difference is alright
740-
assert_image_similar_tofile(img, tempfile, 17)
741-
742733
def test_no_duplicate_0x1001_tag(self) -> None:
743734
# Arrange
744735
tag_ids = {v: k for k, v in ExifTags.TAGS.items()}

Tests/test_shell_injection.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from PIL import GifImagePlugin, Image, JpegImagePlugin
1111

12-
from .helper import cjpeg_available, djpeg_available, is_win32, netpbm_available
12+
from .helper import djpeg_available, is_win32, netpbm_available
1313

1414
TEST_JPG = "Tests/images/hopper.jpg"
1515
TEST_GIF = "Tests/images/hopper.gif"
@@ -42,11 +42,6 @@ def test_load_djpeg_filename(self, tmp_path: Path) -> None:
4242
assert isinstance(im, JpegImagePlugin.JpegImageFile)
4343
im.load_djpeg()
4444

45-
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
46-
def test_save_cjpeg_filename(self, tmp_path: Path) -> None:
47-
with Image.open(TEST_JPG) as im:
48-
self.assert_save_filename_check(tmp_path, im, JpegImagePlugin._save_cjpeg)
49-
5045
@pytest.mark.skipif(not netpbm_available(), reason="Netpbm not available")
5146
def test_save_netpbm_filename_bmp_mode(self, tmp_path: Path) -> None:
5247
with Image.open(TEST_GIF) as im:

src/PIL/JpegImagePlugin.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -845,16 +845,6 @@ def validate_qtables(
845845
)
846846

847847

848-
def _save_cjpeg(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
849-
# ALTERNATIVE: handle JPEGs via the IJG command line utilities.
850-
tempfile = im._dump()
851-
subprocess.check_call(["cjpeg", "-outfile", filename, tempfile])
852-
try:
853-
os.unlink(tempfile)
854-
except OSError:
855-
pass
856-
857-
858848
##
859849
# Factory for making JPEG and MPO instances
860850
def jpeg_factory(

winbuild/build_prepare.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,17 @@ def cmd_msbuild(
149149
},
150150
"build": [
151151
*cmds_cmake(
152-
("jpeg-static", "cjpeg-static", "djpeg-static"),
152+
("jpeg-static", "djpeg-static"),
153153
"-DENABLE_SHARED:BOOL=FALSE",
154154
"-DWITH_JPEG8:BOOL=TRUE",
155155
"-DWITH_CRT_DLL:BOOL=TRUE",
156156
),
157157
cmd_copy("jpeg-static.lib", "libjpeg.lib"),
158-
cmd_copy("cjpeg-static.exe", "cjpeg.exe"),
159158
cmd_copy("djpeg-static.exe", "djpeg.exe"),
160159
],
161160
"headers": ["jconfig.h", r"src\j*.h"],
162161
"libs": ["libjpeg.lib"],
163-
"bins": ["cjpeg.exe", "djpeg.exe"],
162+
"bins": ["djpeg.exe"],
164163
},
165164
"zlib": {
166165
"url": f"https://github.com/zlib-ng/zlib-ng/archive/refs/tags/{V['ZLIBNG']}.tar.gz",

0 commit comments

Comments
 (0)