fix image loading when rotating by 0 deg

This commit is contained in:
homm 2016-08-05 19:20:02 +03:00
parent 4f4c982229
commit 3185262e31
2 changed files with 6 additions and 3 deletions

View File

@ -1572,7 +1572,7 @@ class Image(object):
# Fast paths regardless of filter # Fast paths regardless of filter
if angle == 0: if angle == 0:
return self._new(self.im) return self.copy()
if angle == 180: if angle == 180:
return self.transpose(ROTATE_180) return self.transpose(ROTATE_180)
if angle == 90 and expand: if angle == 90 and expand:

View File

@ -11,11 +11,14 @@ class TestImageRotate(PillowTestCase):
self.assertEqual(out.size, im.size) # default rotate clips output self.assertEqual(out.size, im.size) # default rotate clips output
out = im.rotate(angle, expand=1) out = im.rotate(angle, expand=1)
self.assertEqual(out.mode, mode) 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": for mode in "1", "P", "L", "RGB", "I", "F":
im = hopper(mode) im = hopper(mode)
rotate(im, mode, 45) rotate(im, mode, 45)
for angle in 90, 270: for angle in 0, 90, 180, 270:
im = Image.open('Tests/images/test-card.png') im = Image.open('Tests/images/test-card.png')
rotate(im, im.mode, angle) rotate(im, im.mode, angle)