mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-01 03:33:21 +03:00
Allow ICNS to change size as ICO does
This commit is contained in:
parent
02a2e93703
commit
f7d7a80b5b
|
@ -61,11 +61,10 @@ class TestFileIcns(PillowTestCase):
|
||||||
for w, h, r in im.info['sizes']:
|
for w, h, r in im.info['sizes']:
|
||||||
wr = w * r
|
wr = w * r
|
||||||
hr = h * r
|
hr = h * r
|
||||||
im2 = Image.open(TEST_FILE)
|
im.size = (w, h, r)
|
||||||
im2.size = (w, h, r)
|
im.load()
|
||||||
im2.load()
|
self.assertEqual(im.mode, 'RGBA')
|
||||||
self.assertEqual(im2.mode, 'RGBA')
|
self.assertEqual(im.size, (wr, hr))
|
||||||
self.assertEqual(im2.size, (wr, hr))
|
|
||||||
|
|
||||||
# Check that we cannot load an incorrect size
|
# Check that we cannot load an incorrect size
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
|
|
|
@ -251,8 +251,6 @@ class IcnsImageFile(ImageFile.ImageFile):
|
||||||
self.best_size[0] * self.best_size[2],
|
self.best_size[0] * self.best_size[2],
|
||||||
self.best_size[1] * 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
|
@property
|
||||||
def size(self):
|
def size(self):
|
||||||
|
@ -286,7 +284,8 @@ class IcnsImageFile(ImageFile.ImageFile):
|
||||||
)
|
)
|
||||||
|
|
||||||
Image.Image.load(self)
|
Image.Image.load(self)
|
||||||
if not self.tile:
|
if self.im and self.im.size == self.size:
|
||||||
|
# Already loaded
|
||||||
return
|
return
|
||||||
self.load_prepare()
|
self.load_prepare()
|
||||||
# This is likely NOT the best way to do it, but whatever.
|
# This is likely NOT the best way to do it, but whatever.
|
||||||
|
@ -298,11 +297,6 @@ class IcnsImageFile(ImageFile.ImageFile):
|
||||||
self.im = im.im
|
self.im = im.im
|
||||||
self.mode = im.mode
|
self.mode = im.mode
|
||||||
self.size = im.size
|
self.size = im.size
|
||||||
if self._exclusive_fp:
|
|
||||||
self.fp.close()
|
|
||||||
self.fp = None
|
|
||||||
self.icns = None
|
|
||||||
self.tile = ()
|
|
||||||
self.load_end()
|
self.load_end()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user