Hello community!
I'm one of those users who only jumps for Imagemagick a few times of year when I have a sticky situation I need to get out of...
So I have a directory full of .png files. One instance of a grey color in them is a little off, so I want to replace that color across the board with a new color.
The incorrect color is #C0C0C0 and the desired color is #BFBFBF.
I have tried a few things... but not quite getting the output I need.
Here is what I have tried:
convert * -fill #BFBFBF +opaque #C0C0C0
mogrify *.png -opaque "#C0C0C0" -fill "#BFBFBF"
I think I'm on the right track (been googling like crazy) but not quite there...
Any help greatly appreciated!
Replacing all instances of one color with another
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Replacing all instances of one color with another
The following should work if you are replacing exact colors. If they are not exact, then you need to add -fuzz XX%
I recommand creating another directory to put the result, so you don't mess up the originals. So say the images are in tmp1 and you put the new ones in tmp2 (which you need to create ahead of time)
cd /fullpath2/tmp1
mogrify -path /fullpath2/tmp2 -format png -fill "#BFBFBF" -opaque "#C0C0C0" *.png
see http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/color_basics/#fuzz
The order of your command may be important, so try the above, which should be correct syntax.
I recommand creating another directory to put the result, so you don't mess up the originals. So say the images are in tmp1 and you put the new ones in tmp2 (which you need to create ahead of time)
cd /fullpath2/tmp1
mogrify -path /fullpath2/tmp2 -format png -fill "#BFBFBF" -opaque "#C0C0C0" *.png
see http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/color_basics/#fuzz
The order of your command may be important, so try the above, which should be correct syntax.
Re: Replacing all instances of one color with another
Thanks so much! This worked like a charm
I love internet peeples... ♡
I love internet peeples... ♡