I want to insert an image in another image, I have been able to do so using, per example, img=open('logo.png')
as inserted image and background image background=open('backgroundImg.png')
but when I want to work with askopenfilename
I get this error :
background.paste(img, offset)
AttributeError: 'numpy.ndarray' object has no attribute 'paste'
here is my code :
from PIL import Image
from tkFileDialog import askopenfilename
import cv2
filename1 = askopenfilename(filetypes=[("image","*.png")])
filename2 = askopenfilename(filetypes=[("image","*.png")])
img=cv2.imread(filename1,1)
background=cv2.imread(filename2,1)
img_w, img_h =img.shape[:2]
bg_w, bg_h = background.shape[:2]
offset = ((bg_w - img_w) // 2, (bg_h - img_h) // 2)
background.paste(img, offset)
background.save('savedImg/output.png')