我有一個非常簡單的代碼文件:如何使用枕頭將圖像粘貼到較大的圖像上?
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