Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICO: Add support for different color depths per icon size #6121

Closed
gonzoMD opened this issue Mar 10, 2022 · 4 comments · Fixed by #6122
Closed

ICO: Add support for different color depths per icon size #6121

gonzoMD opened this issue Mar 10, 2022 · 4 comments · Fixed by #6122

Comments

@gonzoMD
Copy link

gonzoMD commented Mar 10, 2022

What did you do?

I took a bunch of pngs of different sizes and wanted to convert them to ICO with different color depths per size

What did you expect to happen?

that I add different images (in terms of color depth) and their sizes to a list and the different images will put into one icon

What actually happened?

there are multiple images of a size added, but all of them are the the same, the last added image

What are your OS, Python and Pillow versions?

  • OS: Kubuntu 21.10
  • Python: Python 3.9.7 (default, Sep 10 2021, 14:59:43)
  • Pillow: 8.1.2
from PIL import Image

images=[]
sizes=[]

#save an icon with three time the same 48x48px image
images.append(Image.open("test.png"))
sizes.append((48,48))
images.append(Image.open("test.png"))
sizes.append((48,48))
images.append(Image.open("test.png"))
sizes.append((48,48))

im = Image.new(mode="RGBA", size=(48,48))
im.save("good.ico", format="ICO", sizes = sizes, append_images = images, bitmap_format="bmp")

images=[]
sizes=[]

#save an icon with three different 48x48px image
images.append(Image.open("test.png")) #original image
sizes.append((48,48))
images.append(Image.new(mode="P", size=(48,48))) # palette image, default bg color
sizes.append((48,48))
images.append(Image.new(mode="P", size=(48,48), color="#ff00ff"))
sizes.append((48,48))

im = Image.new(mode="RGBA", size=(48,48))
im.save("bad.ico", format="ICO", sizes = sizes, append_images = images, bitmap_format="bmp")

I added a zip with an example
test.zip
.

@nulano
Copy link
Contributor

nulano commented Mar 10, 2022

Just to link to it, this is a continuation of #6120.

@radarhere
Copy link
Member

I would think that the last two images you are adding - Image.new(mode="P", size=(48,48)) and Image.new(mode="P", size=(48,48), color="#ff00ff") - are the same color depth. Do you agree?

Even if the specification did allow for multiple images of the same size and same color depth, that doesn't sound like it would be useful.

@gonzoMD
Copy link
Author

gonzoMD commented Mar 11, 2022

Yes, they are. What I want to show here is that the first image, the one opened from file, is not added.

@radarhere
Copy link
Member

I've created PR #6122 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants