-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added ICO saving in BMP format #5513
Conversation
and_mask = Image.new("1", tmp.size) | ||
ImageFile._save( | ||
and_mask, image_io, [("raw", (0, 0) + tmp.size, 0, ("1", 0, -1))] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our 1, L, P and RGB modes don't have any transparency, so the AND mask can just be constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will transparency still work for BMP-formatted ICO images?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RGBA images saved to BMP-formatted ICO will have transparency, because 32-bit images don't require the AND mask (see https://en.wikipedia.org/wiki/ICO_(file_format) for more information).
Looks good, let's also add to release notes. |
Done. |
Thank you! |
Resolves #2512
ICO can either be a container for PNG or BMP.
Pillow has been saving ICOs only in the PNG format. This PR adds support for saving ICOs with the BMP format, largely by reversing the process that we use to load the BMP format. It would be called with
im.save("out.ico", bitmap_format="bmp")