File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626 mypy pypdf --ignore-missing-imports --check-untyped --strict
2727
2828ruff :
29- ruff check --fix pypdf tests make_release.py
29+ ruff check pypdf tests make_release.py
Original file line number Diff line number Diff line change @@ -794,7 +794,7 @@ def decode_stream_data(stream: Any) -> bytes:
794794def _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 ()
You can’t perform that action at this time.
0 commit comments