【发布时间】:2013-12-16 08:27:49
【问题描述】:
我正在尝试使用 Image.paste 功能将 2 个图像组合成一个更大的图像。我首先创建一个可以容纳两个图像的图像,然后粘贴 2 个图像:
wrapper = Image.new("I", (width, height+textHeight));
if placement=="bottom":
wrapper.paste(img1);
wrapper.paste(textImage, (0, height, width, textHeight));
else:
wrapper.paste(textImage);
wrapper.paste(img1, (0,textHeight));
然后我每次都会收到这个错误:
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1127, in paste
self.im.paste(im, box)
ValueError: images do not match
我非常确定图像的大小是正确的,并且包装图像可以容纳两个图像。避免此错误的唯一方法是使 3 个图像(包装器和 2 个组件)大小相同,并从 (0,0) 粘贴。
我无能为力,请帮忙!
【问题讨论】:
标签: python image-processing python-imaging-library pillow