Page 1 of 1

change all pixels of one color to another?

Posted: 2011-10-22T20:15:52-07:00
by iaw4
(OSX or ubuntu, current IM.)

probably a common novice question, but a search here did not give me the answer.

I have a pdf file (in cmyk). I first convert it into a png file. this part is easy with ghostscript. something like

# gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dTextAlphasBits=4 -dGraphicsAlphasBits=4 -r300 -sOutputFile=teststep1.png $@

the part I need help with is that I want to change all pixels that are exactly cyan (1,0,0,0) into, say, rgb blue (0,0,1). just this exact color, not something related (like 0.99,0.01,0,0). is there a magick incantation that accomplishes this?

advice appreciated.

/iaw

Re: change all pixels of one color to another?

Posted: 2011-10-22T22:17:52-07:00
by anthony
Exact may be a little difficult when one image is in one format CMYK, and the desired color is in another format RGB, really at some point either the image (pixels) or the color must be converted into a common format for the comparison to see if they match or match close enough (fuzz factor).

for pixel replacement see..
IM examples, Replacing Colors in Images
http://www.imagemagick.org/Usage/color_basics/#replace

Re: change all pixels of one color to another?

Posted: 2011-10-23T09:55:01-07:00
by iaw4
thanks. this may work...but when it expanded my 3MB pdf file to 100MB, I decided to skip it.

regards,

/iaw

Re: change all pixels of one color to another?

Posted: 2011-10-23T18:57:12-07:00
by anthony
IM is a raster image processor, not a vector image processor (PDF is a vectro image file format)

A word about Vector Image formats
http://www.imagemagick.org/Usage/formats/#vecto