change all pixels of one color to another?

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
iaw4
Posts: 4
Joined: 2010-08-01T07:13:04-07:00
Authentication code: 8675308

change all pixels of one color to another?

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: change all pixels of one color to another?

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
iaw4
Posts: 4
Joined: 2010-08-01T07:13:04-07:00
Authentication code: 8675308

Re: change all pixels of one color to another?

Post by iaw4 »

thanks. this may work...but when it expanded my 3MB pdf file to 100MB, I decided to skip it.

regards,

/iaw
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: change all pixels of one color to another?

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply