From 268be11be6a04e50ffa037ae64f8ff24c2a7a67c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 11 Mar 2022 21:45:37 +1100 Subject: [PATCH] If primary image is already destination size, do not duplicate --- src/PIL/IcoImagePlugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PIL/IcoImagePlugin.py b/src/PIL/IcoImagePlugin.py index 11081e71d..40db16df2 100644 --- a/src/PIL/IcoImagePlugin.py +++ b/src/PIL/IcoImagePlugin.py @@ -56,7 +56,9 @@ def _save(im, fp, filename): fp.write(o16(len(sizes))) # idCount(2) offset = fp.tell() + len(sizes) * 16 bmp = im.encoderinfo.get("bitmap_format") == "bmp" - provided_images = {im.size: im for im in im.encoderinfo.get("append_images", [])} + provided_images = { + im.size: im for im in [im] + im.encoderinfo.get("append_images", []) + } for size in sizes: width, height = size # 0 means 256