mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Do not load ICO if already loaded
This commit is contained in:
parent
a986fed5b4
commit
02a2e93703
BIN
Tests/images/hopper_draw.ico
Normal file
BIN
Tests/images/hopper_draw.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 846 B |
|
@ -1,7 +1,7 @@
|
|||
from .helper import PillowTestCase, hopper
|
||||
|
||||
import io
|
||||
from PIL import Image, IcoImagePlugin
|
||||
from PIL import Image, ImageDraw, IcoImagePlugin
|
||||
|
||||
TEST_ICO_FILE = "Tests/images/hopper.ico"
|
||||
|
||||
|
@ -90,3 +90,16 @@ class TestFileIco(PillowTestCase):
|
|||
im = self.assert_warning(UserWarning,
|
||||
Image.open, "Tests/images/hopper_unexpected.ico")
|
||||
self.assertEqual(im.size, (16, 16))
|
||||
|
||||
def test_draw_reloaded(self):
|
||||
im = Image.open(TEST_ICO_FILE)
|
||||
outfile = self.tempfile("temp_saved_hopper_draw.ico")
|
||||
|
||||
draw = ImageDraw.Draw(im)
|
||||
draw.line((0, 0) + im.size, '#f00')
|
||||
im.save(outfile)
|
||||
|
||||
im = Image.open(outfile)
|
||||
im.save("Tests/images/hopper_draw.ico")
|
||||
reloaded = Image.open("Tests/images/hopper_draw.ico")
|
||||
self.assert_image_equal(im, reloaded)
|
||||
|
|
|
@ -288,6 +288,9 @@ class IcoImageFile(ImageFile.ImageFile):
|
|||
self._size = value
|
||||
|
||||
def load(self):
|
||||
if self.im and self.im.size == self.size:
|
||||
# Already loaded
|
||||
return
|
||||
im = self.ico.getimage(self.size)
|
||||
# if tile is PNG, it won't really be loaded yet
|
||||
im.load()
|
||||
|
|
Loading…
Reference in New Issue
Block a user