Get the color of any screen pixel in an X11 environment.
Simple command-line app to allow you to get the RGB color of any screen
pixel in an X11 environment, even those controlled by another application.
zef install App::pixel-pick
Needs to have the
import utility available. Installed part of the
package. Most Linuxes have it already, if not, install
want to install
libmagickwand-dev as well, though it isn't strictly necessary
for this app.
sudo apt-get install libmagickwand-dev
For Debian based distributions.
If invoked with no positional parameters, runs in interactive mode. Will get the
color of the pixel under the mouse pointer and show the RGB values in both
decimal and hexadecimal formats and will display a small block colored to that
value, Will also display colored blocks of "Named colors", along with their RGB
values, that are "near" the selected color. Will accept an Integer "distance"
parameter at the command line to fine tune the cutoff for what is "near".
(Defaults to 20. More than about 80 or so is not recommended. You'll get
unusefully large numbers of matches.) Will always return at least one "nearest"
color, no matter what the threshold is. The colors may not be exact, they are
just the nearest found in the list. Uses the XKCD and X11 color name lists from
the Color::Names module as its list of known colors.
See https://www.w3schools.com/colors/colors_xkcd.asp XKCD color blocks
And https://www.w3schools.com/colors/colors_x11.asp X11 color blocks
Updates (moderately) slowly as the mouse is moved. There is some delay just to
slow down the "busy" loop of checking to see if the mouse has moved. Will not
attempt to update if the mouse has not moved. Uses the
X11::xdo module to
capture mouse motion so will only work in an X11 environment.
Note that screen sub-pixel dithering may lead to some unexpected values being
returned, especially around small text. The utility returns what the pixel color
is, not what it is perceived to be.
When in interactive mode, you need to send an abort signal to exit the utility.
Control-C will reset your terminal to its previous settings and do a full
clean-up. If you want to keep the color block and values around, do Control-Z
instead. That will also reset the terminal, but will not clean up as much,
effectively leaving the last values displayed.
Non-interactive: (Get the color of the pixel at 100, 200)
pixel-pick 100 200 (--distance=Int)
If invoked with X, Y coordinates, (--distance parameter optional) runs
non-interactive. Gets the pixel color at that coordinate and exits immediately,
doing the partial cleanup as you would get from Control-Z.
Non-interactive, quiet: (Get the RGB values of the pixel at 100, 200)
pixel-pick 100 200 q
Add a truthy value as a "quiet" parameter to not return the standard color
parameters and block. Only returns the RGB values in base 10 separated by
If you would prefer to receive hex values, use an 'h' as the quiet parameter.
Returns the RGB values in hexadecimal, separated by colons;
pixel-pick 100 200 h
2019 thundergnat (Steve Schulze)
This package is free software and is provided "as is" without express or implied
warranty. You can redistribute it and/or modify it under the same terms as Perl
Licensed under The Artistic 2.0; see LICENSE.