Skip to content

Commit

Permalink
fix image loading when rotating by 0 deg
Browse files Browse the repository at this point in the history
  • Loading branch information
homm authored and wiredfool committed Aug 17, 2016
1 parent 9fb400a commit 57addf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ def rotate(self, angle, resample=NEAREST, expand=0):

# 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:
Expand Down
7 changes: 5 additions & 2 deletions Tests/test_image_rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ def rotate(im, mode, angle):
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)

Expand Down

0 comments on commit 57addf0

Please sign in to comment.