Return PixelAccess on first load

This commit is contained in:
Andrew Murray 2025-04-23 21:10:54 +10:00
parent 7a48a9fae0
commit 1e365d8c72
4 changed files with 6 additions and 2 deletions

View File

@ -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)

View File

@ -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

View File

@ -362,7 +362,7 @@ class IcoImageFile(ImageFile.ImageFile):
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

View File

@ -180,7 +180,7 @@ class IptcImageFile(ImageFile.ImageFile):
_im.load()
self.im = _im.im
self.tile = []
return None
return Image.Image.load(self)
Image.register_open(IptcImageFile.format, IptcImageFile)