PIXEL() Function Color Not Accurate?

Hi, I made a macro for picking color at the mouse cursor position from screen, then AppleScript to open the system color picker to show that color:

then I made a screenshot, open that screenshot png file in image editor, compare the color of that same position with the color picked through PIXEL function, they are not same.

the screenshot png file 's color profile is Display P3, is it possible that different color profiles caused this 'not accurate' problem?

here is the macro:

GET COLOR under cursor copy.kmmacros (3.2 KB)

@peternlewis

thanks for any help!

@peternlewis โ€“ did you see @ayrtbh's use of your handle?

I'm curious to know if you were notified when he edited his post to include it.

-Chris

Keyboard Maestro reads the screen to an image, and gets the pixel color from that.

I am definitely no color profile expert, far from it. It is quite likely that the colors will be slightly different in different contexts.

Yes, I got both notifications.

1 Like

Thanks Peter for the reply!

OK I see, I thought there was something wrong here:

"%Calculate%ROUND(65535*PIXEL(Red, MOUSEX(), MOUSEY()))%"

Anyway now happily picking color around, and removed one screen color picking App.

(sorry :-D)

Hi @ayrtbh This is a nice idea. However, unfortunately I can confirm that your Macro does not pick the correct RGB values as you can confirm by using the inbuilt eyedropper in the Apple Color Picker.

Screen Recording 2022-01-25 at 09.26.46-Animated GIFF Small 12fps

The correct RGB values for the blue square above are 146,179,242 but the your Macro shows them as 162.194,245

Like you say the error maybe is in the maths - maybe a rounding error?

But this got me thinking that since the Apple Color Picker itself has an eyedropper tool to select colors (as I used above) why not just make a hot key with Keyboard Maestro to invoke the Color Picker and then use its accurate eye dropper?

After a bit of Googling I found the System Shortcut for the Color Picker is โ‡งโŒ˜C

But it doesn't work in all Apps. The AppleScript to invoke the Color Picker is:

choose color

So, the below Keyboard Maestro Macro works to make โ‡งโŒ˜C open the Color Picker in all Apps. Maybe there is a way to select the eye dropper tool itself using AppleScript?).

Color Picker.kmmacros (15.6 KB)
Color Picker

1 Like

Thanks Zabobon!

The math was borrowed from here:

It says AppleScript's color value is between 0 to 65535, the original math was 'Math.trunc()', I use Round() in Keyboard Maestro instead, the picked color was in 'right direction' but not very close.

1 Like