Pillow
Pillow copied to clipboard
Return PixelAccess from first load of ICO and IPTC images
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.