diff --git a/PyPDFForm/image.py b/PyPDFForm/image.py index 28cb7785..d50f508e 100644 --- a/PyPDFForm/image.py +++ b/PyPDFForm/image.py @@ -42,10 +42,10 @@ def any_image_to_jpg(image_stream: bytes) -> bytes: return image_stream rgb_image = Image.new("RGB", image.size, (255, 255, 255)) - if len(image.split()) == 4: - rgb_image.paste(image, mask=image.split()[3]) - else: - rgb_image.paste(image) + rgb_image.paste( + image, + mask=image.split()[3] if len(image.split()) == 4 else None + ) with BytesIO() as _file: rgb_image.save(_file, format="JPEG")