From 55d8283b3e14eb595ac6785813fa7d2f0311b783 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 15 Nov 2023 11:06:38 +1100 Subject: [PATCH] Pad PDF palette to 256 entries when saving --- src/PIL/PdfImagePlugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PIL/PdfImagePlugin.py b/src/PIL/PdfImagePlugin.py index 09fc0c7e6ce..bf5f637fda3 100644 --- a/src/PIL/PdfImagePlugin.py +++ b/src/PIL/PdfImagePlugin.py @@ -93,6 +93,7 @@ def _write_image(im, filename, existing_pdf, image_refs): elif im.mode == "P": filter = "ASCIIHexDecode" palette = im.getpalette() + palette += (768 - len(palette)) * [0] dict_obj["ColorSpace"] = [ PdfParser.PdfName("Indexed"), PdfParser.PdfName("DeviceRGB"),