Replace black with red via ImageMagick?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
MyNameIsNotRelevant
Posts: 1
Joined: 2014-12-13T18:17:31-07:00
Authentication code: 6789

Replace black with red via ImageMagick?

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Replace black with red via ImageMagick?

Post 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
Post Reply