ImageMagick get pixel color by x y coordinates

Viewed 327

I have this 30x20 image which is 10x increased in size here:

enter image description here

I need to get the color of the pixel with the coordinates x 19 and y 14 which in this case is red

I changed all kind of values in this code:

-crop "1x1+0+%[fx:h-7]+0" -format "%[hex:u.p{0,0}]\n" info:

but only get the blue pixel

2 Answers

If you want pixel at (19,14), you need:

magick image.png -format "%[hex:u.p{19,14}]\n" info:

Or:

magick image.png -crop 1x1+19+14 -format "%[hex:u.p{0,0}]\n" info:

You can do that with %[pixel:u.p{x,y}] in Imagemagick. So for you zoomed image:

convert img.png -format "%[pixel:u.p{185,134}]\n" info:

srgb(255,0,0)

and for your original image:

convert img.png -format "%[pixel:u.p{19,14}]\n" info:
Related