How to measure (true) luminosity of a color sample by script?
Let's say I have just picked a foreground color with the eye dropper.
The script to read RGB values I have...
var Colour = app.foregroundColor;
var R = Colour.rgb.red.toFixed(2);
var G = Colour.rgb.green.toFixed(2);
var B = Colour.rgb.blue.toFixed(2);
Now, how can I get the true luminosity value of this sample? (which I would use to set Blend-If Gray settings, with some adjustments)
Can I just calculate this somehow from the RGB numbers, or does a virtual measurement need to be taken?
As you may know, some claim that the TRUE luminosity is not always what PS is using, but we should. AFAIK, you can get this number, for instance, by measuring after you've added a Solid Color layer (any gray) on top in Color mode. This indeed matches with what I expected.
So are there at least two ways?
(1) Maybe some simple recalculation/parameter that brings the near perfect value?
(2) A method where I temporarily add this mentioned layer on top (with the script) and do a new measurement for the perfect value?
The problem here is that if my cursor has moved, the script would sample in the wrong location... I've also read warnings not to sample from within a script. I could fill a temp layer with the fg color though, and work from there...
Example of what I want ...
Let's say I have an area of Red: 255, G: 0, B: 0
When I measure with the gray layer on top, values are 76, 76, 76
I want a method to get to the 76 (in this case).
