From 3d7e0e6812b0398cb9bcc9c2d55cfef5d66a2e3f Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 14 Jun 2021 18:34:46 +0200 Subject: [PATCH] allow palette PNG images with ICC profile (closes: #107) --- src/img2pdf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index bbaac34..8407221 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -823,7 +823,9 @@ class pdfdoc(object): elif color == Colorspace.CMYK or color == Colorspace["CMYK;I"]: iccpdict[PdfName.N] = 4 elif color == Colorspace.P: - raise Exception("Cannot have Palette images with ICC profile") + # Only the png format can have an icc profile as well as a + # color palette. A png palette is always RGB. + iccpdict[PdfName.N] = 3 colorspace = [PdfName.ICCBased, iccpdict] # either embed the whole jpeg or deflate the bitmap representation