我一直在用 PIL 在 python 中搞乱,我正在研究一个在 4 个象限中镜像和图像的函数。显然我遇到了错误,而且我似乎无法弄清楚。我的功能如下:
def mirror_four(image):
x = image.size[0]
y = image.size[1]
temp = Image.new("RGB", (image.size[0], image.size[1]), "black")
tl = image
tr = mirror_left(image)
bl = mirror_verticle(image)
br = mirror_verticle(tr)
image.paste(temp,(0,0,int(x/2),int(y/2)),tl)
image.paste(temp,(int(x/2),0,0,int(y/2)),tr)
image.paste(temp,(0,int(y/2),int(x/2),0),bl)
image.paste(temp,(x/2,y/2,x,y),br)
return temp
Run Code Online (Sandbox Code Playgroud)
这将返回错误:ValueError:图像不匹配
我有点迷失,PIL 文档对我没有多大帮助。