Skip to content

Return PixelAccess from first load of ICO and IPTC images #8922

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

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.

1 participant