serisAK
serisAK

Reputation: 43

Change color of specific pixels [Wand]

So, I'm using Wand Python Library to mess around with some images.

I just want it to look at an image, pixel by pixel, and for each pixel that is a specific color, say '4d4d4d', replace that pixels color to something else, like '#00ff00'. That's it. I've thoroughly scoured the documentation and I can't for the life of me figure out how to do this.

Upvotes: 2

Views: 986

Answers (1)

serisAK
serisAK

Reputation: 43

If anyone is interested the python code would be something like this:

from wand.image import Image
from wand.drawing import Drawing
from wand.color import Color

with Drawing() as draw:
    draw.fill_color = Color('#00ff00')
    draw.color(x,y,'replace')
    with Image(filename='image.jpg') as img:
        draw(img)
        img.save(filename='new_image.jpg')

Upvotes: 1

Related Questions