diff --git a/PIL/Image.py b/PIL/Image.py index a3171aeaa..84122655a 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1558,10 +1558,10 @@ class Image(object): resample = NEAREST 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': - return self.convert('RGBa').resize(size, resample).convert('RGBA') + return self.convert('RGBa').resize(size, resample, box).convert('RGBA') self.load() diff --git a/Tests/test_image_resample.py b/Tests/test_image_resample.py index bbdbf2a02..17461c868 100644 --- a/Tests/test_image_resample.py +++ b/Tests/test_image_resample.py @@ -451,6 +451,15 @@ class CoreResampleBoxTest(PillowTestCase): with self.assertRaisesRegexp(AssertionError, "difference 29\."): 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__': unittest.main()