You are not logged in.

#1 2019-12-25 17:42:48

synftw
Member
Registered: 2017-02-03
Posts: 22

Looking for a package to determine a pixel's color

I'm looking for a ricing tool that I'm sure must exist but I'm having no luck finding through search queries. Basically, you would execute the program, a crosshair pops up on the screen, hover over a specific pixel and hit enter and a color code is output somewhere. In this way I won't have to hunt through config files for color codes to clean up my environment. Anyone know the best solution?

Thanks.

*** Solved! grabc is the software, thank you Wibjarm! ***

edit: still having issues

Last edited by synftw (2019-12-25 18:29:08)

Offline

#2 2019-12-25 18:11:18

Wibjarm
Member
Registered: 2012-05-04
Posts: 43

Re: Looking for a package to determine a pixel's color

Sounds like grabc is probably exactly what you want.  Run it, click a pixel, recieve hex code on stdout.

Offline

#3 2019-12-25 18:20:49

synftw
Member
Registered: 2017-02-03
Posts: 22

Re: Looking for a package to determine a pixel's color

Wibjarm wrote:

Sounds like grabc is probably exactly what you want.  Run it, click a pixel, recieve hex code on stdout.


Just installed off the aur and... that was EXACTLY what I was looking for!!! Thank you so much, this community is amazing.

Offline

#4 2019-12-25 18:30:46

synftw
Member
Registered: 2017-02-03
Posts: 22

Re: Looking for a package to determine a pixel's color

Still having issues, it looks like grabc determines that everything is #000000 regardless of where I click (the use-case right now is fixing the powerline color inconsistencies I'm having with kitty tabs). Maybe some kind of a configuration issue?

https://i.imgur.com/oxYYZ0Y.png

Mod Edit - Replaced oversized image with link.
CoC - Pasting pictures and code

Last edited by Slithery (2019-12-25 18:36:27)

Offline

#5 2019-12-25 18:49:46

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: Looking for a package to determine a pixel's color

I've always used scrot and imagemagic for this - though I've never wanted to target a specific pixel as this is error-prone particularly in antialiased regions.

I just 'scrot -s' to get a small area, then use imagemagic to convert this to a color histogram (and sort by number of pixels of each color) to get the dominant color(s).

For example, this script will do it:

#!/bin/sh

scrot -s /tmp/getcol.png

convert /tmp/getcol.png \
	-define histogram:unique-colors=true \
	-format %c histogram:info:- | \
	sort -nr | \
	sed -n '1s/[^#]*\([^ ]*\).*/\1/p'

Last edited by Trilby (2019-12-25 18:54:34)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2019-12-25 20:29:31

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 74,254

Re: Looking for a package to determine a pixel's color

Output of "grabc -d"?
Do you by any chance run a wayland session (sway?)?

Offline

#7 2019-12-25 21:32:03

synftw
Member
Registered: 2017-02-03
Posts: 22

Re: Looking for a package to determine a pixel's color

seth wrote:

Output of "grabc -d"?
Do you by any chance run a wayland session (sway?)?

For the center of a solid blue region it's:

[Debug]:   Root Window Id: 0x000001a1
[Debug]: Target Window Id: 0x0200000e  X,Y: +327+334
[Debug]: Color: #000000
#000000

Offline

#8 2019-12-25 21:46:43

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Looking for a package to determine a pixel's color

I have the same problem with grabc here. It sometimes works and sometimes doesn't. It seems to depend on the window. It worked on the Firefox window but didn't work on other places of the desktop. I tried disabling the compositor but that didn't help.

I use Xorg and xfwm4 and picom/compton.

Offline

#9 2019-12-25 21:51:51

synftw
Member
Registered: 2017-02-03
Posts: 22

Re: Looking for a package to determine a pixel's color

Trilby wrote:
#!/bin/sh

scrot -s /tmp/getcol.png

convert /tmp/getcol.png \
	-define histogram:unique-colors=true \
	-format %c histogram:info:- | \
	sort -nr | \
	sed -n '1s/[^#]*\([^ ]*\).*/\1/p'

Very beginner question, I'm sure, but when I execute this script it closes the terminal emulator immediately after running before I can see an output. Should I be executing some other way?

Offline

#10 2019-12-25 22:09:57

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,100

Re: Looking for a package to determine a pixel's color

Run it from an actual terminal rather than clicking on it from a GUI

Online

#11 2019-12-25 22:54:08

synftw
Member
Registered: 2017-02-03
Posts: 22

Re: Looking for a package to determine a pixel's color

V1del wrote:

Run it from an actual terminal rather than clicking on it from a GUI

I was running it through kitty with exec getcol.sh (which I renamed it to). It kills the kitty instance upon resolution.

Offline

#12 2019-12-25 23:01:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,100

Re: Looking for a package to determine a pixel's color

Don't use exec, it replaces the parent process (i.e. your shell) with the child process. Set the executable bit and just run it

chmod +x getcol.sh
./getcol.sh

Last edited by V1del (2019-12-25 23:04:25)

Online

Board footer

Powered by FluxBB