我采集了一些图片,但是是透明背景的,我需要把他改成白色。
解决方法from PIL import Image
imagePtah = r'E:Pythontest1.png'
img = Image.open(imagePtah)
if img.mode != 'RGBA':
image = img.convert('RGBA')
width = img.width
height = img.height
img2 = Image.new('RGB', size=(width, height), color=(255, 255, 255))
img2.paste(img, (0, 0), mask=img)
img2.show()
阅读原文



