I was having a bad time with Image.rotate()
on PIL
until I decided to check on a terminal what was going on. This is what I did:
Python 2, Pillow (2.8.1)
from PIL import Image
im = Image.new('RGB', (800, 500))
im.size
out = im.rotate(90)
out.size
Output (as expected):
>> (800, 500)
>> (500, 800)
Python 3, Pillow (3.1.1)
from PIL import Image
im = Image.new('RGB', (800, 500))
im.size
out = im.rotate(90)
out.size
Output:
>> (800, 500)
>> (800, 500)
And I think that's the right way to call rotate in Pillow 3X. Here's the documentation for the function:
Image.Rotate() Am I missing something?
It was a bug in Pillow<=2.9.0, fixed in 3.0.0. If you want the image to change size when rotated, you need to include the expand argument, eg img.rotate(-90, expand=1). See this issue for details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.