-
I am writing a script which converts linux icon themes to Windows icons (Win XP Standard 16,32 and 48px bmp icons). Adding the 32bit icons works perfectly, but I can't add the lower color ones. ( here is a code snippet: if "colordepth" in inputfile:
for color in inputfile["colordepth"]:
if color == 32:
images.append(Image.open(tempfile))
sizes.append(tempsize)
else:
print(color)
#im = Image.new(mode="P", size=tempsize)
#images.append(im)
#sizes.append(tempsize)
else:
images.append(Image.open(tempfile))
sizes.append(tempsize)
im = Image.new(mode="RGBA", size=(48,48))
im.save(output_file, format="ICO", sizes = sizes, append_images = images, bitmap_format="bmp") Here is the complete source file: https://github.com/gonzoMD/IconThemeConverter/blob/master/IconThemeConverter.py Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Bitmap saving was added in #5513. Looking at the code, this is not possible.
Looking at the code, the following formats are supported: Pillow/src/PIL/BmpImagePlugin.py Lines 291 to 297 in 397a940 So both 8-bit pallete and 24-bit RGB are supported, but not 4-bit pallete or 16-bit pallete. These formats are supported when reading: Pillow/src/PIL/BmpImagePlugin.py Lines 38 to 46 in 397a940 If you require support for these other color depths, I would suggest opening an issue with your feature request: https://github.com/python-pillow/Pillow/issues/new/choose As a side note, this looks like an updated version of the guide you linked: https://docs.microsoft.com/en-us/windows/win32/uxguide/vis-icons Personally, I would not recommend using Pillow to save in ICO format if you wish to strictly adhere to Microsoft documentation. However, PNG or 32-bit BMP seems to work for most modern uses (e.g. favicons). |
Beta Was this translation helpful? Give feedback.
Bitmap saving was added in #5513. Looking at the code, this is not possible.
Looking at the code, the following formats are supported:
Pillow/src/PIL/BmpImagePlugin.py
Lines 291 to 297 in 397a940
So both 8-bit pallete and 24-bit RGB are supported, but not 4-bit pallete or 16-bit pallete.
Monochrome or 8-bit grayscale are also supported.
These format…