Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #3875

When calling the ICO load() method, it does not just load the image the first time, but on subsequent times as well, since the size might have changed. Here is an example of the size changing, since this is not normal image behaviour -

>>> from PIL import Image
>>> im = Image.open("Tests/images/python.ico")
>>> im.info['sizes']
{(16, 16), (48, 48), (32, 32)}
>>> im.size
(48, 48)
>>> im.im.size
(48, 48)
>>> im.size = (32, 32)
>>> im.im.size
(48, 48)
>>> im.load()
>>> im.im.size
(32, 32)

This caused the issue in question, as load() is called during save by _ensure_mutable(), and that reloading is overwriting any changes that were made. The solution is to not reload the image if the size is the same.

While investigating this problem, I found that it was not occurring with ICNS. Since ICO and ICNS are similar, I wanted to know what ICNS was doing differently to solve the issue. It turns out that ICNS does not support the size being changed after load like ICO does. So this PR also adds that functionality.

@hugovk hugovk merged commit ac6185c into python-pillow:master Jun 19, 2019
@radarhere radarhere deleted the load branch June 19, 2019 10:24
@radarhere radarhere mentioned this pull request Apr 20, 2021
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 this pull request may close these issues.

Draw on a ico file without having to convert to png

2 participants