change the color of a single specified pixel

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
melisen

change the color of a single specified pixel

Post by melisen »

Hi all.

I want to change the color of a single specified pixel and save the result in another file.

So far I have managed to change a specified pixel to black

Code: Select all

convert /Users/anders/Desktop/teest2.png -draw ‘color 395,324 point' /Users/anders/Desktop/teest3.png 
But how do I specify which color I want the pixel to be?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: change the color of a single specified pixel

Post by el_supremo »

Precede the -color command with
-fill yellow
or
-fill rgb(255,255,0)
which with a Q8 IM will also be yellow, or equivalently,
-fill rgb(100%,100%,0)
which will do the same thing in Q8 and Q16.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
melisen

Re: change the color of a single specified pixel

Post by melisen »

Do you mean
convert /Users/anders/Desktop/teest2.png -draw -fill yellow ‘color 395,324 point' /Users/anders/Desktop/teest3.png
?

I have tried but no luck. I have tried a number of variations that didn´t work either:
convert /Users/anders/Desktop/teest2.png -draw -fill yellow ‘color 395,324 point' /Users/anders/Desktop/teest3.png

convert /Users/anders/Desktop/teest2.png -draw '-fill yellow color 395,324 point' /Users/anders/Desktop/teest3.png

convert /Users/anders/Desktop/teest2.png -draw '-fill yellow 395,324 point' /Users/anders/Desktop/teest3.png

convert /Users/anders/Desktop/teest2.png -fill yellow 'color 395,324 point' /Users/anders/Desktop/teest3.png
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: change the color of a single specified pixel

Post by el_supremo »

Sorry, I don't know how I got that so drastically wrong.
I meant before the -draw:

Code: Select all

convert /Users/anders/Desktop/teest2.png -fill yellow -draw ‘color 395,324 point' /Users/anders/Desktop/teest3.png
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: change the color of a single specified pixel

Post by anthony »

-fill is done outside -draw inside -draw use 'fill' Don' forget the quotes, -draw only takes one argument.

Code: Select all

    -fill yellow -draw 'color 395,324 point'
or

Code: Select all

    -draw 'fill yellow color 395,324 point'
NOTE: their is a difference between 'point 395,324' and 'color 395,324 point' The first is overlay the color, the second is replace the color.But this is only if drawing transparent colors....

See Im Examples Draw 'Color Fill Primatives'
http://www.imagemagick.org/Usage/draw/#color
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply