-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
What did you do?
Apply rotation of 90*N degrees to an image, with expand set to True.
What did you expect to happen?
Because the rotation is a multiple of 90 degrees, I expected the image to be rotated with no translations. I expected the result to match a rotation via Image.transpose.
What actually happened?
- For 0 degrees, no visible difference (Working as intended)
- For -90 degrees, the image is translated by (1+x, 1+y), but expands only in height. This results in the right-most column being cropped.
- For +90 degrees, the image is translated by (1+x, 1+y), but expands only in width. This results in the bottom-most row being cropped.
- For ±90*(2, 3, ..., N-1, N) degrees, the image is translated by (1+x, 1+y), and expands to fit the image.
What versions of Pillow and Python are you using?
Pillow 3.2.0; Python 3.4.4 and Python 3.5.1
from PIL import Image, ImageDraw
im = Image.new('RGBA', (11,13), 'white')
# Add markers to corners to check for any cropping
w, h = im.size
draw = ImageDraw.Draw(im)
draw.line((0, 0, 1, 1), fill='cyan')
draw.line((0, h-1, 1, h-2), fill='magenta')
draw.line((w-1, h-1, w-2, h-2), fill='yellow')
draw.line((w-1, 0, w-2, 1), fill='black')
del draw
im.show()
print(' deg : old -> new')
for i in range(-4, 5):
deg = i * 90
im2 = im.rotate(deg, expand=True)
print('{:>5} : {}x{} -> {}x{}'.format(deg, im.width, im.height, im2.width, im2.height))
im2.show()homm, Puneet-Singh1996, dodo020206 and mara004Puneet-Singh1996
Metadata
Metadata
Assignees
Labels
No labels