Clear pyaccess after re-assigning im

This commit is contained in:
Andrew Murray 2022-12-23 23:20:06 +11:00
parent edcfe09f12
commit b0f1d2ed8d
2 changed files with 14 additions and 0 deletions

View File

@ -71,6 +71,19 @@ def test_save_to_bytes():
)
def test_getpixel(tmp_path):
temp_file = str(tmp_path / "temp.ico")
im = hopper()
im.save(temp_file, "ico", sizes=[(32, 32), (64, 64)])
with Image.open(temp_file) as reloaded:
reloaded.load()
reloaded.size = (32, 32)
assert reloaded.getpixel((0, 0)) == (18, 20, 62)
def test_no_duplicates(tmp_path):
temp_file = str(tmp_path / "temp.ico")
temp_file2 = str(tmp_path / "temp2.ico")

View File

@ -327,6 +327,7 @@ class IcoImageFile(ImageFile.ImageFile):
# if tile is PNG, it won't really be loaded yet
im.load()
self.im = im.im
self.pyaccess = None
self.mode = im.mode
if im.size != self.size:
warnings.warn("Image was not the expected size")