I would like to change a single color with Python.
If a fast solution with PIL exists, I would prefer this solution.
At the moment, I use
c
I've just came up with this solution:
import Image
im = Image.open("MyImage.png")
width, height = im.size
colortuples = im.getcolors()
mycolor1 = min(colortuples)[1]
mycolor2 = max(colortuples)[1]
pix = im.load()
for x in range(0, width):
for y in range(0, height):
if pix[x,y] == mycolor1:
im.putpixel((x, y), mycolor2)
im.save('MyImage.png')
Although putpixel isn't fast, it seems to be fast enough for me.