From 3185262e316acd8da315f64ae4c39563016ea117 Mon Sep 17 00:00:00 2001 From: homm Date: Fri, 5 Aug 2016 19:20:02 +0300 Subject: [PATCH] fix image loading when rotating by 0 deg --- PIL/Image.py | 2 +- Tests/test_image_rotate.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 64f461358..4283b640c 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1572,7 +1572,7 @@ class Image(object): # Fast paths regardless of filter if angle == 0: - return self._new(self.im) + return self.copy() if angle == 180: return self.transpose(ROTATE_180) if angle == 90 and expand: diff --git a/Tests/test_image_rotate.py b/Tests/test_image_rotate.py index 26c0bd729..3b2319fb0 100644 --- a/Tests/test_image_rotate.py +++ b/Tests/test_image_rotate.py @@ -11,11 +11,14 @@ class TestImageRotate(PillowTestCase): self.assertEqual(out.size, im.size) # default rotate clips output out = im.rotate(angle, expand=1) self.assertEqual(out.mode, mode) - self.assertNotEqual(out.size, im.size) + if angle % 180 == 0: + self.assertEqual(out.size, im.size) + else: + self.assertNotEqual(out.size, im.size) for mode in "1", "P", "L", "RGB", "I", "F": im = hopper(mode) rotate(im, mode, 45) - for angle in 90, 270: + for angle in 0, 90, 180, 270: im = Image.open('Tests/images/test-card.png') rotate(im, im.mode, angle)