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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tests/test_file_ico.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_getpixel(tmp_path: Path) -> None:
reloaded.load()
reloaded.size = (32, 32)

assert reloaded.load() is not None
assert reloaded.getpixel((0, 0)) == (18, 20, 62)


Expand Down
3 changes: 3 additions & 0 deletions Tests/test_file_iptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def test_open() -> None:
assert im.tile == [("iptc", (0, 0, 1, 1), 25, "raw")]
assert_image_equal(im, expected)

with Image.open(f) as im:
assert im.load() is not None


def test_getiptcinfo_jpg_none() -> None:
# Arrange
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/IcoImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def load(self) -> Image.core.PixelAccess | None:
self.info["sizes"] = set(sizes)

self.size = im.size
return None
return Image.Image.load(self)

def load_seek(self, pos: int) -> None:
# Flag the ImageFile.Parser so that it
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/IptcImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def load(self) -> Image.core.PixelAccess | None:
with Image.open(o) as _im:
_im.load()
self.im = _im.im
return None
self.tile = []
return Image.Image.load(self)


Image.register_open(IptcImageFile.format, IptcImageFile)
Expand Down
Loading