Skip to content

Commit aee07f0

Browse files
committed
Adopting review feedbacks
1 parent 81283d1 commit aee07f0

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ mypy:
2626
mypy pypdf --ignore-missing-imports --check-untyped --strict
2727

2828
ruff:
29-
ruff check --fix pypdf tests make_release.py
29+
ruff check pypdf tests make_release.py

pypdf/filters.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ def decode_stream_data(stream: Any) -> bytes:
794794
def _xobj_to_image(
795795
x_object: dict[str, Any],
796796
pillow_parameters: Union[dict[str, Any], None] = None
797-
) -> tuple[Optional[str], bytes, Any]:
797+
) -> tuple[Optional[str], bytes, Any]:
798798
"""
799799
Users need to have the pillow package installed.
800800
@@ -955,10 +955,12 @@ def _apply_alpha(
955955
if pillow_parameters is None:
956956
pillow_parameters = {}
957957
# Preserve JPEG image quality - see issue #3515.
958-
if image_format == "JPEG" and "quality" not in pillow_parameters:
959-
pillow_parameters["quality"] = "keep"
960-
# This prevent: Cannot use 'keep' when original image is not a JPEG:
961-
img.format = image_format # type: ignore
958+
if image_format == "JPEG":
959+
# This prevents: Cannot use 'keep' when original image is not a JPEG:
960+
# "JPEG" is the value of PIL.JpegImagePlugin.JpegImageFile.format
961+
img.format = "JPEG" # type: ignore[misc]
962+
if "quality" not in pillow_parameters:
963+
pillow_parameters["quality"] = "keep"
962964

963965
# Save image to bytes
964966
img_byte_arr = BytesIO()

0 commit comments

Comments
 (0)