Use opencv in python to save png images with alpha channel

Look directly at the python code below

 

def save_png():
    image_path = 'src.png'
    img = cv2.imread(image_path, cv2.IMREAD_UNCHANGED) 
    img[63,63,:] = [255,0,0,128]
    print(img)
    cv2.imwrite('dst.png', img, [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
    cv2.namedWindow('win', 0)
    cv2.imshow('win', img)
    cv2.waitKey(0)

reference

https://blog.csdn.net/litdaguang/article/details/45438297

https://www.jianshu.com/p/7fcfc6253c81

Guess you like

Origin blog.csdn.net/bcfd_yundou/article/details/90480378