我有一张小尺寸的图片文件(300x300),我想要将整个图像“粘贴”到一个我使用PIL创建的较大图像的特定位置上(2400x1700)。以下是我的代码:
from PIL import Image
im = Image.new("RGB", (2400, 1700), "white")
im2 = Image.open("smallimage.jpg")
im.paste(im2, (20,20,300,300))
im.save("test.png")
The error I get is
Traceback (most recent call last):
File "chart.py", line 6, in <module>
im.paste(im2, (20,20,300,300))
File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 1351, in paste
self.im.paste(im, box)
ValueError: images do not match
有没有一种方法可以将较小的图像复制/粘贴到较大的图像上,而不对较小的图像进行任何变换(如裁剪)?