Using ImageMagick:
$ convert image.png -crop '1x1+100+200' txt:-
Outputs, e.g.
# ImageMagick pixel enumeration: 1,1,255,rgb
0,0: (236,236,236) #ECECEC rgb(236,236,236)
Or, if the file is PNG-24 file, it outputs e.g.
# ImageMagick pixel enumeration: 1,1,255,rgba
0,0: ( 0, 0, 0,243) #000000F3 rgba(0,0,0,0.952941)
At -crop
option I've first defined the area to be cropped, which in this case is 1x1 pixels. Then I've defined the location of the crop relative to the North West corner, i.e. upper left.†
Lastly I've converted the output to textual with txt:-
. ImageMagick then outputs all the colors of the image to STDOUT (in this case there is only one color, as the image size is 1 pixel), meaning you could process it with normal shell techniques. So e.g. by piping the output to tail -n 1
you would get only the pixel info line.
If you need the pixel's color in any other colorspace, you should look at the aptly named -colorspace
option.
†) Actually the location is relative to the specified -gravity
value, but it defaults to "NorthWest".