如何从PIL中的功能读取图像

时间:2018-10-23 11:39:50

标签: python python-imaging-library

如何从PIL中的功能读取图像?在此场景中,我正在通过paste_image函数传递图像,但它不支持PIL

def paste_image(image):
    for i in range(epoches):
        im2 = Image.open('/home/navaneeth/work/oneon/1.png')
        x, y = im2.size
        image.paste(im2, (0, 0, x, y))
        image.save("test_"+str(i)+".jpg", "JPEG")

我收到此错误

Traceback (most recent call last):
File "main.py", line 109, in <module>
paste_image(image)
File "main.py", line 98, in paste_image
image.paste(im2, (0, 0, x, y))
AttributeError: 'numpy.ndarray' object has no attribute 'paste'

1 个答案:

答案 0 :(得分:0)

from PIL import Image
im2 = Image.open("/home/navaneeth/work/oneon/1.png")

您可以使用此代码获得所需的结果。