【问题标题】:rotating only a part of the image in python在python中仅旋转图像的一部分
【发布时间】:2012-07-15 05:33:38
【问题描述】:

抱歉,在编码方面我完全是个菜鸟。 我有一个使用 Python 仅旋转图像的一部分的问题。我已经导入了 PIL 并且旋转功能正常工作,但我不能让它只旋转图像的一部分。任何帮助将不胜感激。

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()

我有类似的东西

【问题讨论】:

    标签: python python-imaging-library


    【解决方案1】:

    我会提出以下解决方案:

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

    x1,y1 是 inlay/sub-image 的左上角,x2,y2 是右下角。

    img = myImage 来自您的示例

    【讨论】:

      猜你喜欢
      • 2017-01-04
      • 2018-03-30
      • 2015-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-31
      相关资源
      最近更新 更多