Skip to content

Conversation

@radarhere
Copy link
Member

ICO and IPTC load() return None the first time processing data, leading to the following assertions failing.

from PIL import Image
with Image.open("Tests/images/hopper.png") as im:
    im.save("out.ico", sizes=[(32, 32), (64, 64)])
with Image.open("out.ico") as reloaded:
    reloaded.size = (32, 32)
    assert reloaded.load() is not None

and

import io
from PIL import Image
f = io.BytesIO(
    b"\x1c\x03<\x00\x02\x01\x00\x1c\x03x\x00\x01\x01\x1c\x03\x14\x00\x01\x01"
    b"\x1c\x03\x1e\x00\x01\x01\x1c\x08\n\x00\x01\x00"
)
with Image.open(f) as im:
    assert im.load() is not None

This fixes that, and also prevents repeated IPTC load() calls from regenerating the C image instance.

@hugovk hugovk merged commit 935e9e4 into python-pillow:main Jun 27, 2025
62 of 64 checks passed
@radarhere radarhere deleted the load branch June 27, 2025 15:17
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.

2 participants