2

Sorry, I'm a complete noob when it comes to coding. I've got a question for rotating only a portion of the image using Python. I already have PIL imported and the rotate function working but I can't make it rotate only a portion of the image. Any help would be greatly appreciated.

from PIL import Image
import _imaging
import sys

myImage = Image.open("img.gif")

for x in range():
    for y in range():
        myImage.rotate(90).show()

I have something like that

0

1 Answer 1

0

i would propose the following solution:

inlay = img.crop((x1,y1,x2,y2)).rotate(90)
img.paste(inlay, (x1,y1,x2,y2))

x1,y1 is the left upper corner and x2,y2 the lower right corner of the inlay/sub-image.

img = myImage from your example

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.