mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
return copy of the image if size matches
This commit is contained in:
parent
9947794ccd
commit
d4784bffb2
|
@ -1544,7 +1544,7 @@ class Image(object):
|
|||
|
||||
size = tuple(size)
|
||||
if self.size == size:
|
||||
return self._new(self.im)
|
||||
return self.copy()
|
||||
|
||||
if self.mode in ("1", "P"):
|
||||
resample = NEAREST
|
||||
|
|
|
@ -24,6 +24,15 @@ class TestImagingResampleVulnerability(PillowTestCase):
|
|||
with self.assertRaises(ValueError):
|
||||
im.resize((100, -100))
|
||||
|
||||
def test_modify_after_resizing(self):
|
||||
im = hopper('RGB')
|
||||
# get copy with same size
|
||||
copy = im.resize(im.size)
|
||||
# some in-place operation
|
||||
copy.paste('black', (0, 0, im.width // 2, im.height // 2))
|
||||
# image should be different
|
||||
self.assertNotEqual(im.tobytes(), copy.tobytes())
|
||||
|
||||
|
||||
class TestImagingCoreResampleAccuracy(PillowTestCase):
|
||||
def make_case(self, mode, size, color):
|
||||
|
|
Loading…
Reference in New Issue
Block a user