ソースコード
import glob from PIL import Image directory_path = "【フォルダのパス】/**/*.png" files = glob.glob(directory_path, recursive=True) for path in files: image = Image.open(path) image = image.convert("P") palette = image.getpalette() palette[255 * 3 + 0] = 255 palette[255 * 3 + 1] = 0 palette[255 * 3 + 2] = 255 image.putpalette(palette) image.save(path)