how to get the color value of a point?
how to get the color value of a point?
which is similar with color picker.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to get the color value of a point?
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: how to get the color value of a point?
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.
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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to get the color value of a point?
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?
thank you , very good answer.