src/img2pdf.py: do not allow transparency

This commit is contained in:
Johannes 'josch' Schauer 2018-07-17 16:26:32 +02:00
parent 90293204b2
commit 84ce9bbd9c
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -828,12 +828,8 @@ def read_images(rawdata, colorspace, first_frame_only=False):
Colorspace["CMYK;I"], Colorspace.P]: Colorspace["CMYK;I"], Colorspace.P]:
logging.debug("Colorspace is OK: %s", color) logging.debug("Colorspace is OK: %s", color)
newimg = imgdata newimg = imgdata
elif color in [Colorspace.RGBA, Colorspace.other]:
logging.debug("Converting colorspace %s to RGB", color)
newimg = imgdata.convert('RGB')
color = Colorspace.RGB
else: else:
raise ValueError("unknown colorspace: %s" % color.name) raise ValueError("unknown or unsupported colorspace: %s" % color.name)
# cheapo version to retrieve a PNG encoding of the payload is to # cheapo version to retrieve a PNG encoding of the payload is to
# just save it with PIL. In the future this could be replaced by # just save it with PIL. In the future this could be replaced by
# dedicated function applying the Paeth PNG filter to the raw pixel # dedicated function applying the Paeth PNG filter to the raw pixel