1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| from PIL import Image
original_path = 'xxxx' original_file = 'cc.png' target_path = 'xxx'
image = Image.open(original_path+original_file).convert("RGBA")
white_background = Image.new("RGBA", image.size, "WHITE")
white_background.paste(image, (0, 0), image)
final_image = white_background.convert("RGB") final_image.save(target_path+original_file)
final_image.show()
|