adapt AlphaChannelError messages

This commit is contained in:
Johannes Schauer Marin Rodrigues 2021-10-03 21:03:08 +02:00
parent 09ad147d97
commit 392d4a665e
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1230,16 +1230,11 @@ def get_imgmetadata(
if depth > 8: if depth > 8:
logger.warning("Image with transparency and a bit depth of %d." % depth) logger.warning("Image with transparency and a bit depth of %d." % depth)
logger.warning("This is unsupported due to PIL limitations.") logger.warning("This is unsupported due to PIL limitations.")
raise AlphaChannelError("Refusing to work with multiple >8bit channels.") raise AlphaChannelError(
elif (ics in ["LA", "PA", "RGBA"] or "transparency" in imgdata.info): "Refusing to work with multiple >8bit channels."
logger.warning("Image contains transparency which cannot be retained in PDF.") )
logger.warning("img2pdf will not perform a lossy operation.") elif ics in ["LA", "PA", "RGBA"] or "transparency" in imgdata.info:
logger.warning("You can remove the alpha channel using imagemagick:") raise AlphaChannelError("This function must not be called on images with alpha")
logger.warning(
" $ convert input.png -background white -alpha "
"remove -alpha off output.png"
)
raise AlphaChannelError("Refusing to work on images with alpha channel")
# Since commit 07a96209597c5e8dfe785c757d7051ce67a980fb or release 4.1.0 # Since commit 07a96209597c5e8dfe785c757d7051ce67a980fb or release 4.1.0
# Pillow retrieves the DPI from EXIF if it cannot find the DPI in the JPEG # Pillow retrieves the DPI from EXIF if it cannot find the DPI in the JPEG