Use plugin method directly when saving PDFs (#9547)

This commit is contained in:
Andrew Murray 2026-05-06 23:51:16 +10:00 committed by GitHub
parent 6a05e34b69
commit f693a3a0e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,10 +148,14 @@ def _write_image(
strip_size=math.ceil(width / 8) * height,
)
elif decode_filter == "DCTDecode":
Image.SAVE["JPEG"](im, op, filename)
from . import JpegImagePlugin
JpegImagePlugin._save(im, op, filename)
elif decode_filter == "JPXDecode":
from . import Jpeg2KImagePlugin
del dict_obj["BitsPerComponent"]
Image.SAVE["JPEG2000"](im, op, filename)
Jpeg2KImagePlugin._save(im, op, filename)
else:
msg = f"unsupported PDF filter ({decode_filter})"
raise ValueError(msg)