Compare commits
2 commits
fc059ee471
...
0cbcb8fa12
Author | SHA1 | Date | |
---|---|---|---|
0cbcb8fa12 | |||
e9e04b6dd9 |
2 changed files with 24 additions and 18 deletions
|
@ -1432,8 +1432,10 @@ def get_imgmetadata(
|
|||
iccp = None
|
||||
if "icc_profile" in imgdata.info:
|
||||
iccp = imgdata.info.get("icc_profile")
|
||||
# GIMP saves bilevel tiff images with an RGB ICC profile which
|
||||
# is useless and produces an error in Adobe Acrobat -- ignore it
|
||||
# GIMP saves bilevel tiff images with an RGB ICC profile which is useless
|
||||
# and produces an error in Adobe Acrobat, so we ignore it with a warning.
|
||||
# imagemagick also used to (wrongly) include an RGB ICC profile for bilevel
|
||||
# images: https://github.com/ImageMagick/ImageMagick/issues/2070
|
||||
if iccp is not None and color == Colorspace["1"] and imgformat == ImageFormat.TIFF:
|
||||
with io.BytesIO(iccp) as f:
|
||||
prf = ImageCms.ImageCmsProfile(f)
|
||||
|
@ -1442,10 +1444,8 @@ def get_imgmetadata(
|
|||
and prf.profile.manufacturer == "GIMP"
|
||||
and prf.profile.profile_description == "GIMP built-in sRGB"
|
||||
):
|
||||
logger.warning(
|
||||
"Ignoring RGB ICC profile in bilevel TIFF produced by GIMP."
|
||||
)
|
||||
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/9518")
|
||||
logger.warning("Ignoring RGB ICC profile in bilevel TIFF produced by GIMP.")
|
||||
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/3438")
|
||||
iccp = None
|
||||
|
||||
logger.debug("width x height = %dpx x %dpx", imgwidthpx, imgheightpx)
|
||||
|
@ -2101,7 +2101,16 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
|||
)
|
||||
)
|
||||
else:
|
||||
if (
|
||||
if color in [Colorspace.P, Colorspace.PA] and iccp is not None:
|
||||
# PDF does not support palette images with icc profile
|
||||
if color == Colorspace.P:
|
||||
newcolor = Colorspace.RGB
|
||||
newimg = newimg.convert(mode="RGB")
|
||||
elif color == Colorspace.PA:
|
||||
newcolor = Colorspace.RGBA
|
||||
newimg = newimg.convert(mode="RGBA")
|
||||
smaskidat = None
|
||||
elif (
|
||||
color == Colorspace.RGBA
|
||||
or color == Colorspace.LA
|
||||
or color == Colorspace.PA
|
||||
|
@ -2115,6 +2124,11 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
|||
newcolor = color
|
||||
l, a = newimg.split()
|
||||
newimg = l
|
||||
elif color == Colorspace.PA or (
|
||||
color == Colorspace.P and "transparency" in newimg.info
|
||||
):
|
||||
newcolor = color
|
||||
a = newimg.convert(mode="RGBA").split()[-1]
|
||||
else:
|
||||
newcolor = Colorspace.RGBA
|
||||
r, g, b, a = newimg.convert(mode="RGBA").split()
|
||||
|
@ -2125,15 +2139,6 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
|||
"Image contains an alpha channel. Computing a separate "
|
||||
"soft mask (/SMask) image to store transparency in PDF."
|
||||
)
|
||||
elif color in [Colorspace.P, Colorspace.PA] and iccp is not None:
|
||||
# PDF does not support palette images with icc profile
|
||||
if color == Colorspace.P:
|
||||
newcolor = Colorspace.RGB
|
||||
newimg = newimg.convert(mode="RGB")
|
||||
elif color == Colorspace.PA:
|
||||
newcolor = Colorspace.RGBA
|
||||
newimg = newimg.convert(mode="RGBA")
|
||||
smaskidat = None
|
||||
else:
|
||||
newcolor = color
|
||||
smaskidat = None
|
||||
|
|
|
@ -4276,9 +4276,10 @@ def gif_transparent_pdf(tmp_path_factory, gif_transparent_img, request):
|
|||
== b"q\n45.0000 0 0 45.0000 0.0000 0.0000 cm\n/Im0 Do\nQ"
|
||||
)
|
||||
assert p.pages[0].Resources.XObject.Im0.BitsPerComponent == 8
|
||||
assert p.pages[0].Resources.XObject.Im0.ColorSpace == "/DeviceRGB"
|
||||
assert p.pages[0].Resources.XObject.Im0.ColorSpace[0] == "/Indexed"
|
||||
assert p.pages[0].Resources.XObject.Im0.ColorSpace[1] == "/DeviceRGB"
|
||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.BitsPerComponent == 8
|
||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Colors == 3
|
||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Colors == 1
|
||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Predictor == 15
|
||||
assert p.pages[0].Resources.XObject.Im0.Filter == "/FlateDecode"
|
||||
assert p.pages[0].Resources.XObject.Im0.Height == 60
|
||||
|
|
Loading…
Reference in a new issue