Reputation: 132
I am trying to make an image transparent. This is my image
from PIL import Image
img = Image.open('Frame 0001.png')
img = img.convert("RGBA")
datas = img.getdata()
newData = []
for item in datas:
if item[0] == 255 and item[1] == 255 and item[2] == 255:
newData.append((255, 255, 255, 0))
else:
newData.append(item)
img.putdata(newData)
img.save("img2.png", "PNG")
Upvotes: 0
Views: 540
Reputation: 132
Well Googled a bit and found a package called cv2. Had a tough time installing that package, but the thing I was trying to do was possible
import cv2
img1=cv2.imread('m1.jpg')
img2=cv2.imread('logo.jpg')
dst=cv2.addWeighted(img1,0.7,img2,0.3,0)
cv2.imshow('dst',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
Upvotes: 1