Page 1 of 1

how to get the color value of a point?

Posted: 2011-08-15T05:51:35-07:00
by linjuming
Image

which is similar with color picker.

Re: how to get the color value of a point?

Posted: 2011-08-15T06:21:33-07:00
by linjuming
Image

Re: how to get the color value of a point?

Posted: 2011-08-15T11:13:42-07:00
by fmw42
looks like a bug in Imagick.

try this in the PHP exec() command to get 8-bit RGB values.

convert im_logo_examples.gif[1x1+140+160] -format "%[fx:floor(255*u.r)],%[fx:floor(255*u.g)],%[fx:floor(255*u.b)]" info:
2,90,164

Re: how to get the color value of a point?

Posted: 2011-08-15T17:05:59-07:00
by anthony
See IM examples, Quantization and Dithering, extracting image colors
http://www.imagemagick.org/Usage/quantize/#extract

It first talks about all the colors, but then goes to methods for getting the color of a specify pixel.

The best way from command line is to either use a -format FX/Pixel escape to get a specific pixel values, or to crop the image down to just that one pixel and then use format or txt: output.

Code: Select all

convert rose: -format '%[pixel:p{40,30}]' info:-
rgb(232,54,58)

Code: Select all

convert rose: -crop 1x1+40+30 -depth 8 txt:
# ImageMagick pixel enumeration: 1,1,255,rgb
0,0: (232, 54, 58) #E8363A rgb(232,54,58)

Re: how to get the color value of a point?

Posted: 2011-08-15T17:52:10-07:00
by fmw42
The trouble with [pixel: ...] is that sometimes it returns a color name and not an rgb triplet. That was why I used [fx: ...] in my example.

Re: how to get the color value of a point?

Posted: 2011-08-15T19:20:13-07:00
by linjuming
thank you , very good answer.