Page 1 of 1

Replace black with red via ImageMagick?

Posted: 2014-12-13T18:22:37-07:00
by MyNameIsNotRelevant
I have a bunch of images (jpg) which are simply black and white; no gray; no color. I want to be able to change them to red and white. Can ImageMagick help do this quickly/easily? I have over 100 images to do this with. So, any batch processing ideas would be appreciated.

Re: Replace black with red via ImageMagick?

Posted: 2014-12-13T22:11:51-07:00
by fmw42
It is hard to know without an example. You could post one to some free hosting service such as dropbox.com and put the link here. But if it is as you say, then

unix syntax is:

Code: Select all

convert image.jpg -fuzz XX% -fill red -opaque black newimage.jpg
should work. The -fuzz XX% is in case the jpg quantization changes some value to gray rather than pure black and white. If it does not you can either leave it out or set it to 0.

Also what platform and version of IM are you using?

If you want to do this on a folder of images, use mogrify

Code: Select all

cd folder1
mogrify -path path2/folder2 -format jpg -fuzz XX% -fill red -opaque black *.jpg
where folder1 has your images and folder2 is an empty folder to put the results, so you do not walk over the input images.

see
http://www.imagemagick.org/Usage/basics/#mogrify