Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python PIL - Rotate an image around a point that isn't the center

Is it possible to rotate an image around a point that isn't the image center using PIL?

If not what could you folk recommend for me to achieve the desired behavior?

like image 267
Michael Avatar asked Oct 29 '22 05:10

Michael


1 Answers

By default, it rotates around the center of the image, to answer the commenter's question. Otherwise, you can specify coordinates, starting from the top left.

from PIL import Image
im = Image.new("RGB", (100, 100))
resultIm = im.rotate(45, center=(25, 25))

See https://pillow.readthedocs.io/en/5.2.x/reference/Image.html#PIL.Image.Image.rotate for documentation.

like image 57
radarhere Avatar answered Nov 15 '22 06:11

radarhere