我有一个非常简单的代码文件:如何使用枕头将图像粘贴到较大的图像上?
from PIL import Image
til = Image.new("RGB",(50,50))
im = Image.open("tile.png") #25x25
til.paste(im)
til.paste(im,(23,0))
til.paste(im,(0,23))
til.paste(im,(23,23))
til.save("testtiles.png")
然而,当我尝试运行它,我得到以下错误:
Traceback (most recent call last):
til.paste(im)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1340, in paste
self.im.paste(im, box)
ValueError: images do not match
是什么原因造成这个错误?他们都是RGB图像,文档没有说这个错误。
通常当2张图像的模式不匹配时。 – runDOSrun 2015-02-09 10:53:37