mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-12 09:12:22 +03:00
Remove unused _save_cjpeg (#9084)
This commit is contained in:
commit
7b1ba29b5b
|
@ -291,16 +291,6 @@ def djpeg_available() -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def cjpeg_available() -> bool:
|
|
||||||
if shutil.which("cjpeg"):
|
|
||||||
try:
|
|
||||||
subprocess.check_call(["cjpeg", "-version"])
|
|
||||||
return True
|
|
||||||
except subprocess.CalledProcessError: # pragma: no cover
|
|
||||||
return False
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def netpbm_available() -> bool:
|
def netpbm_available() -> bool:
|
||||||
return bool(shutil.which("ppmquant") and shutil.which("ppmtogif"))
|
return bool(shutil.which("ppmquant") and shutil.which("ppmtogif"))
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ from .helper import (
|
||||||
assert_image_equal_tofile,
|
assert_image_equal_tofile,
|
||||||
assert_image_similar,
|
assert_image_similar,
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
cjpeg_available,
|
|
||||||
djpeg_available,
|
djpeg_available,
|
||||||
hopper,
|
hopper,
|
||||||
is_win32,
|
is_win32,
|
||||||
|
@ -731,14 +730,6 @@ class TestFileJpeg:
|
||||||
img.load_djpeg()
|
img.load_djpeg()
|
||||||
assert_image_similar_tofile(img, TEST_FILE, 5)
|
assert_image_similar_tofile(img, TEST_FILE, 5)
|
||||||
|
|
||||||
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
|
|
||||||
def test_save_cjpeg(self, tmp_path: Path) -> None:
|
|
||||||
with Image.open(TEST_FILE) as img:
|
|
||||||
tempfile = str(tmp_path / "temp.jpg")
|
|
||||||
JpegImagePlugin._save_cjpeg(img, BytesIO(), tempfile)
|
|
||||||
# Default save quality is 75%, so a tiny bit of difference is alright
|
|
||||||
assert_image_similar_tofile(img, tempfile, 17)
|
|
||||||
|
|
||||||
def test_no_duplicate_0x1001_tag(self) -> None:
|
def test_no_duplicate_0x1001_tag(self) -> None:
|
||||||
# Arrange
|
# Arrange
|
||||||
tag_ids = {v: k for k, v in ExifTags.TAGS.items()}
|
tag_ids = {v: k for k, v in ExifTags.TAGS.items()}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import pytest
|
||||||
|
|
||||||
from PIL import GifImagePlugin, Image, JpegImagePlugin
|
from PIL import GifImagePlugin, Image, JpegImagePlugin
|
||||||
|
|
||||||
from .helper import cjpeg_available, djpeg_available, is_win32, netpbm_available
|
from .helper import djpeg_available, is_win32, netpbm_available
|
||||||
|
|
||||||
TEST_JPG = "Tests/images/hopper.jpg"
|
TEST_JPG = "Tests/images/hopper.jpg"
|
||||||
TEST_GIF = "Tests/images/hopper.gif"
|
TEST_GIF = "Tests/images/hopper.gif"
|
||||||
|
@ -42,11 +42,6 @@ class TestShellInjection:
|
||||||
assert isinstance(im, JpegImagePlugin.JpegImageFile)
|
assert isinstance(im, JpegImagePlugin.JpegImageFile)
|
||||||
im.load_djpeg()
|
im.load_djpeg()
|
||||||
|
|
||||||
@pytest.mark.skipif(not cjpeg_available(), reason="cjpeg not available")
|
|
||||||
def test_save_cjpeg_filename(self, tmp_path: Path) -> None:
|
|
||||||
with Image.open(TEST_JPG) as im:
|
|
||||||
self.assert_save_filename_check(tmp_path, im, JpegImagePlugin._save_cjpeg)
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not netpbm_available(), reason="Netpbm not available")
|
@pytest.mark.skipif(not netpbm_available(), reason="Netpbm not available")
|
||||||
def test_save_netpbm_filename_bmp_mode(self, tmp_path: Path) -> None:
|
def test_save_netpbm_filename_bmp_mode(self, tmp_path: Path) -> None:
|
||||||
with Image.open(TEST_GIF) as im:
|
with Image.open(TEST_GIF) as im:
|
||||||
|
|
|
@ -845,16 +845,6 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _save_cjpeg(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
|
||||||
# ALTERNATIVE: handle JPEGs via the IJG command line utilities.
|
|
||||||
tempfile = im._dump()
|
|
||||||
subprocess.check_call(["cjpeg", "-outfile", filename, tempfile])
|
|
||||||
try:
|
|
||||||
os.unlink(tempfile)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Factory for making JPEG and MPO instances
|
# Factory for making JPEG and MPO instances
|
||||||
def jpeg_factory(
|
def jpeg_factory(
|
||||||
|
|
|
@ -149,18 +149,17 @@ DEPS: dict[str, dict[str, Any]] = {
|
||||||
},
|
},
|
||||||
"build": [
|
"build": [
|
||||||
*cmds_cmake(
|
*cmds_cmake(
|
||||||
("jpeg-static", "cjpeg-static", "djpeg-static"),
|
("jpeg-static", "djpeg-static"),
|
||||||
"-DENABLE_SHARED:BOOL=FALSE",
|
"-DENABLE_SHARED:BOOL=FALSE",
|
||||||
"-DWITH_JPEG8:BOOL=TRUE",
|
"-DWITH_JPEG8:BOOL=TRUE",
|
||||||
"-DWITH_CRT_DLL:BOOL=TRUE",
|
"-DWITH_CRT_DLL:BOOL=TRUE",
|
||||||
),
|
),
|
||||||
cmd_copy("jpeg-static.lib", "libjpeg.lib"),
|
cmd_copy("jpeg-static.lib", "libjpeg.lib"),
|
||||||
cmd_copy("cjpeg-static.exe", "cjpeg.exe"),
|
|
||||||
cmd_copy("djpeg-static.exe", "djpeg.exe"),
|
cmd_copy("djpeg-static.exe", "djpeg.exe"),
|
||||||
],
|
],
|
||||||
"headers": ["jconfig.h", r"src\j*.h"],
|
"headers": ["jconfig.h", r"src\j*.h"],
|
||||||
"libs": ["libjpeg.lib"],
|
"libs": ["libjpeg.lib"],
|
||||||
"bins": ["cjpeg.exe", "djpeg.exe"],
|
"bins": ["djpeg.exe"],
|
||||||
},
|
},
|
||||||
"zlib": {
|
"zlib": {
|
||||||
"url": f"https://github.com/zlib-ng/zlib-ng/archive/refs/tags/{V['ZLIBNG']}.tar.gz",
|
"url": f"https://github.com/zlib-ng/zlib-ng/archive/refs/tags/{V['ZLIBNG']}.tar.gz",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user