Compare commits
No commits in common. "0cbcb8fa124bf7c65373a98e526595da00d3580f" and "fc059ee471aca7819c82bea1ebc3f4ce6b737399" have entirely different histories.
0cbcb8fa12
...
fc059ee471
2 changed files with 18 additions and 24 deletions
|
@ -1432,10 +1432,8 @@ def get_imgmetadata(
|
||||||
iccp = None
|
iccp = None
|
||||||
if "icc_profile" in imgdata.info:
|
if "icc_profile" in imgdata.info:
|
||||||
iccp = imgdata.info.get("icc_profile")
|
iccp = imgdata.info.get("icc_profile")
|
||||||
# GIMP saves bilevel tiff images with an RGB ICC profile which is useless
|
# GIMP saves bilevel tiff images with an RGB ICC profile which
|
||||||
# and produces an error in Adobe Acrobat, so we ignore it with a warning.
|
# is useless and produces an error in Adobe Acrobat -- ignore it
|
||||||
# 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:
|
if iccp is not None and color == Colorspace["1"] and imgformat == ImageFormat.TIFF:
|
||||||
with io.BytesIO(iccp) as f:
|
with io.BytesIO(iccp) as f:
|
||||||
prf = ImageCms.ImageCmsProfile(f)
|
prf = ImageCms.ImageCmsProfile(f)
|
||||||
|
@ -1444,8 +1442,10 @@ def get_imgmetadata(
|
||||||
and prf.profile.manufacturer == "GIMP"
|
and prf.profile.manufacturer == "GIMP"
|
||||||
and prf.profile.profile_description == "GIMP built-in sRGB"
|
and prf.profile.profile_description == "GIMP built-in sRGB"
|
||||||
):
|
):
|
||||||
logger.warning("Ignoring RGB ICC profile in bilevel TIFF produced by GIMP.")
|
logger.warning(
|
||||||
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/3438")
|
"Ignoring RGB ICC profile in bilevel TIFF produced by GIMP."
|
||||||
|
)
|
||||||
|
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/9518")
|
||||||
iccp = None
|
iccp = None
|
||||||
|
|
||||||
logger.debug("width x height = %dpx x %dpx", imgwidthpx, imgheightpx)
|
logger.debug("width x height = %dpx x %dpx", imgwidthpx, imgheightpx)
|
||||||
|
@ -2101,16 +2101,7 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if color in [Colorspace.P, Colorspace.PA] and iccp is not None:
|
if (
|
||||||
# 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
|
color == Colorspace.RGBA
|
||||||
or color == Colorspace.LA
|
or color == Colorspace.LA
|
||||||
or color == Colorspace.PA
|
or color == Colorspace.PA
|
||||||
|
@ -2124,11 +2115,6 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
||||||
newcolor = color
|
newcolor = color
|
||||||
l, a = newimg.split()
|
l, a = newimg.split()
|
||||||
newimg = l
|
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:
|
else:
|
||||||
newcolor = Colorspace.RGBA
|
newcolor = Colorspace.RGBA
|
||||||
r, g, b, a = newimg.convert(mode="RGBA").split()
|
r, g, b, a = newimg.convert(mode="RGBA").split()
|
||||||
|
@ -2139,6 +2125,15 @@ def read_images(rawdata, colorspace, first_frame_only=False, rot=None):
|
||||||
"Image contains an alpha channel. Computing a separate "
|
"Image contains an alpha channel. Computing a separate "
|
||||||
"soft mask (/SMask) image to store transparency in PDF."
|
"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:
|
else:
|
||||||
newcolor = color
|
newcolor = color
|
||||||
smaskidat = None
|
smaskidat = None
|
||||||
|
|
|
@ -4276,10 +4276,9 @@ 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"
|
== 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.BitsPerComponent == 8
|
||||||
assert p.pages[0].Resources.XObject.Im0.ColorSpace[0] == "/Indexed"
|
assert p.pages[0].Resources.XObject.Im0.ColorSpace == "/DeviceRGB"
|
||||||
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.BitsPerComponent == 8
|
||||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Colors == 1
|
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Colors == 3
|
||||||
assert p.pages[0].Resources.XObject.Im0.DecodeParms.Predictor == 15
|
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.Filter == "/FlateDecode"
|
||||||
assert p.pages[0].Resources.XObject.Im0.Height == 60
|
assert p.pages[0].Resources.XObject.Im0.Height == 60
|
||||||
|
|
Loading…
Reference in a new issue