简体   繁体   English

在python中仅旋转图像的一部分

[英]rotating only a part of the image in python

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. 我有一个问题,希望使用Python旋转图像的仅一部分。 I already have PIL imported and the rotate function working but I can't make it rotate only a portion of the image. 我已经导入了PIL,并且可以使用旋转功能,但是不能使其仅旋转图像的一部分。 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 我有这样的东西

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. x1,y1是镶嵌图像/子图像的左上角,x2,y2是镶嵌图像/子图像的右下角。

img = myImage from your example img =您示例中的myImage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM