How to rotate image around custom point in Pillow?

Let’s learn how to rotate image around custom point in Pillow.
how to rotate custom point image

Pillow rotate image

To rotate an image around a custom point, adjust the rotation’s pivot by specifying new coordinates. This is basically to change the center of the image to the different coordinates.

By default, image rotation occurs around the image’s top-left corner. By parameter you are able to set a new coordinates.

from PIL import Image

my_image = Image.open("C:/Users/Pythoneo/Documents/image.jpg")

rotated_image = my_image.rotate(180, center=(500, 500))
rotated_image.show()

The center parameter defines new pivot coordinates, shifting the pivot 500 pixels right and 500 pixels down.

See also  How to rotate a matrix with Numpy

By specifying the center parameter in the rotate function, you can change the center of rotation for the image.