It took me a while to figure this out but I was happy with the results and figured this might help someone else. I had about 100 two color .png files that I wanted to change the color on. I didn’t feel like editing each one by hand in an image editor so I stumbled on imagemagick.
I am on a Mac (OSX) so I installed it via brew:
➜ ~ brew install imagemagick Warning: imagemagick-6.9.2-4 already installed ➜ ~
As you can see, I had already installed it. It was obvious, but here’s the command I eventually came up with:
convert filename.png -fuzz 25% -fill "#000000" -opaque "#4e9db3" filename_new.png
The infile is obvious. The “-fuzz 25%” seemed to make the entire replacement more thorough. If I went above 25% I found all the colors were replaced. The “-fill” tells imagemagick what you want to use as the replacement color. The “-opaque” is what you are replacing. To make it easier for me, I also outputted my altered file into a sub folder. Here’s how I looped through all the files:
for i in *.png : do convert $i -fuzz 25% -fill "#000000" -opaque "#4e9db3" done/$i done
And off it went. I was very happy with this result. You can read more about it here: Replacing Colors in an Image