mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +03:00
test for common modes and filters
pass box for RGBA → RGBa conversion
This commit is contained in:
parent
cf25722a73
commit
77210e410d
|
@ -1558,10 +1558,10 @@ class Image(object):
|
||||||
resample = NEAREST
|
resample = NEAREST
|
||||||
|
|
||||||
if self.mode == 'LA':
|
if self.mode == 'LA':
|
||||||
return self.convert('La').resize(size, resample).convert('LA')
|
return self.convert('La').resize(size, resample, box).convert('LA')
|
||||||
|
|
||||||
if self.mode == 'RGBA':
|
if self.mode == 'RGBA':
|
||||||
return self.convert('RGBa').resize(size, resample).convert('RGBA')
|
return self.convert('RGBa').resize(size, resample, box).convert('RGBA')
|
||||||
|
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
|
|
@ -451,6 +451,15 @@ class CoreResampleBoxTest(PillowTestCase):
|
||||||
with self.assertRaisesRegexp(AssertionError, "difference 29\."):
|
with self.assertRaisesRegexp(AssertionError, "difference 29\."):
|
||||||
self.assert_image_similar(reference, without_box, 5)
|
self.assert_image_similar(reference, without_box, 5)
|
||||||
|
|
||||||
|
def test_formats(self):
|
||||||
|
for resample in [Image.NEAREST, Image.BILINEAR]:
|
||||||
|
for mode in ['RGB', 'L', 'RGBA', 'LA', 'I', '']:
|
||||||
|
im = hopper(mode)
|
||||||
|
box = (20, 20, im.size[0] - 20, im.size[1] - 20)
|
||||||
|
with_box = im.resize((32, 32), resample, box)
|
||||||
|
cropped = im.crop(box).resize((32, 32), resample)
|
||||||
|
self.assert_image_similar(cropped, with_box, 0.4)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user