ignore RGB icc profile for grayscale jpegs produced by SmartAlbums

closes: #175
This commit is contained in:
Leo 2023-10-17 11:31:51 +02:00 committed by Johannes Schauer Marin Rodrigues
parent 09064e8e70
commit f157ced05d
Signed by: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -1478,6 +1478,26 @@ def get_imgmetadata(
)
logger.warning("https://gitlab.gnome.org/GNOME/gimp/-/issues/3438")
iccp = None
# SmartAlbums old version (found 2.2.6) exports JPG with only 1 compone
# with an RGB ICC profile which is useless.
# This produces an error in Adobe Acrobat, so we ignore it with a warning.
if iccp is not None and (
(color == Colorspace["L"] and imgformat == ImageFormat.JPEG)
):
exifsoft = None
if hasattr(imgdata, "_getexif") and imgdata._getexif() is not None:
for tag, value in imgdata._getexif().items():
if TAGS.get(tag, tag) == "Software":
exifsoft = value
with io.BytesIO(iccp) as f:
prf = ImageCms.ImageCmsProfile(f)
if (prf.profile.model and "sRGB" in prf.profile.model) and (
exifsoft and "SmartAlbums" in exifsoft
):
logger.warning(
"Ignoring RGB ICC profile in Grayscale JPG created by SmartAlbums"
)
iccp = None
logger.debug("width x height = %dpx x %dpx", imgwidthpx, imgheightpx)