Forground Color not accurate

I am trying to retrieve the Foregroundcolor in Photoshop and have found that when using this method

app.foregroundColor.rgb

{
    "desc": {
        "_obj": "HSBColorClass",
        "hue": {
            "_unit": "angleUnit",
            "_value": 128.4686279296875
        },
        "saturation": 54.90196078431372,
        "brightness": 47.84313725490196
    }
}
blue: undefined
green: undefined
hexValue: "ANANAN"
red: undefined
typename: "RGBColor"

the RGB values are undefinded.

When i get the color over a batchplay:

const color = await action.batchPlay([{
          _obj: "get",
          _target: [
             {
                _ref: "application",
                _enum: "ordinal",
                _value: "targetEnum"
             }
          ],
          _options: {
             dialogOptions: "dontDisplay"
          }
     }], 
{});

I get this value:

{
    "_obj": "RGBColor",
    "red": 55.00389105058366,
    "grain": 122,
    "blue": 64
}

Which is not always 100% accurate with the values shown in the color picker.

is there a way to get exactly the color that is listed in the picker?

It would help everyone if you formatted the code with ``` before and after code blocks

thanks for the tip i did not know that

I just tried to get RGB color and it works only in 3 cases:

  • Ps is just opened
  • Reset colors to default
  • If you check one of RGB values in the picker before selecting:

Otherwise, if you had it changed, colors are undefined or ANANAN

Yes, I can confirm that FG color has error and currently works only with RGB. The fix is ready in the review stage along with a few others.

2 Likes

Ping @MalbertCunha
Check Jardas reply above