Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在PIL(枕头)中旋转椭圆_Python_Python Imaging Library - Fatal编程技术网

Python 如何在PIL(枕头)中旋转椭圆

Python 如何在PIL(枕头)中旋转椭圆,python,python-imaging-library,Python,Python Imaging Library,因此,我想在我的图像上添加旋转椭圆(具有一定的透明度)。我该怎么做?我这样做: def create_ellipse(fi): ellipse = Image.new('RGBA', (4*b, b*2), (255,255,255,0)) draw_ellipse = ImageDraw.Draw(ellipse, "RGBA") draw = ImageDraw.Draw(im, 'RGBA') for l in range(b, -1, -1):

因此,我想在我的图像上添加旋转椭圆(具有一定的透明度)。我该怎么做?我这样做:

def create_ellipse(fi):
    ellipse = Image.new('RGBA', (4*b, b*2), (255,255,255,0))
    draw_ellipse = ImageDraw.Draw(ellipse, "RGBA")
    draw = ImageDraw.Draw(im, 'RGBA')
    for l in range(b, -1, -1):
        colour = (red, green, blue, int(alpha/(b)))
        draw_ellipse.ellipse((b*2-l*2, b-l, b*2+l*2, b+l), fill=colour)
    rotated = ellipse.rotate(fi, expand=1, resample=Image.BICUBIC)
    im.paste(rotated, (x0-2*b, y0-b), rotated)
    return im

但是我的主图片背景是灰色的,所以我在不透明度方面有一些问题。

示例代码中没有定义许多变量,这使得诊断变得更困难-b、红色、绿色、蓝色、alpha、im、x0和y0。fi也很好。使用以下值,您的代码似乎可以正常工作—fi=45、b=100、红色=100、绿色=150、蓝色=200、alpha=10000、im=Image.new('RGB'、(500500)、'#bbb')、x0=50、y0=50