mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +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)
|
size = tuple(size)
|
||||||
if self.size == size:
|
if self.size == size:
|
||||||
return self._new(self.im)
|
return self.copy()
|
||||||
|
|
||||||
if self.mode in ("1", "P"):
|
if self.mode in ("1", "P"):
|
||||||
resample = NEAREST
|
resample = NEAREST
|
||||||
|
|
|
@ -24,6 +24,15 @@ class TestImagingResampleVulnerability(PillowTestCase):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
im.resize((100, -100))
|
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):
|
class TestImagingCoreResampleAccuracy(PillowTestCase):
|
||||||
def make_case(self, mode, size, color):
|
def make_case(self, mode, size, color):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user