Skip to content

Commit

Permalink
Allow ICNS to change size as ICO does
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Jun 11, 2019
1 parent 02a2e93 commit f7d7a80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 4 additions & 5 deletions Tests/test_file_icns.py
Expand Up @@ -61,11 +61,10 @@ def test_sizes(self):
for w, h, r in im.info['sizes']:
wr = w * r
hr = h * r
im2 = Image.open(TEST_FILE)
im2.size = (w, h, r)
im2.load()
self.assertEqual(im2.mode, 'RGBA')
self.assertEqual(im2.size, (wr, hr))
im.size = (w, h, r)
im.load()
self.assertEqual(im.mode, 'RGBA')
self.assertEqual(im.size, (wr, hr))

# Check that we cannot load an incorrect size
with self.assertRaises(ValueError):
Expand Down
10 changes: 2 additions & 8 deletions src/PIL/IcnsImagePlugin.py
Expand Up @@ -251,8 +251,6 @@ def _open(self):
self.best_size[0] * self.best_size[2],
self.best_size[1] * self.best_size[2],
)
# Just use this to see if it's loaded or not yet.
self.tile = ("",)

@property
def size(self):
Expand Down Expand Up @@ -286,7 +284,8 @@ def load(self):
)

Image.Image.load(self)
if not self.tile:
if self.im and self.im.size == self.size:
# Already loaded
return
self.load_prepare()
# This is likely NOT the best way to do it, but whatever.
Expand All @@ -298,11 +297,6 @@ def load(self):
self.im = im.im
self.mode = im.mode
self.size = im.size
if self._exclusive_fp:
self.fp.close()
self.fp = None
self.icns = None
self.tile = ()
self.load_end()


Expand Down

0 comments on commit f7d7a80

Please sign in to comment.