we have a Python script:
from PIL import Image, ImageOps, ImageFilter
import cv2
import numpy as np
def remove_trans(image):
#Replace transparency on image with white background
image = image.convert('RGBA')
new_image = Image.new("RGBA", image.size, "WHITE") # Create a white rgba background
new_image.paste(image, (0, 0), image) # Paste the image on the background.
new_image = new_image.convert('RGB')
return new_image
img = Image.open('test.png')
img1 = remove_trans(img)
img1.save('NO_ALPHA_PNG.png')
print(img.mode)
img = img.convert('LA')
img = img.convert('1')
img.save('PNG_filter.png')
However we have a bug there. When we load a transparent png image, and then "process" the image with the script, the transparent background is very weird. We found out the reason is the dithering. but we havent found any solution so far. Anybody knows how to get the background transparent, with dithering also?
After process
Original