diff --git a/src/img2pdf.py b/src/img2pdf.py index 68e94f4..42c695a 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -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)