Copy link to clipboard
Copied
We use a javascript using Action Manager code to retrieve the color of a Color Overlay Layer Effect on the current layer.
We've been using the same script since Photoshop CS6, and I just confirmed that it still works in PS CC2021, CC2022, and CC2023. But not in Beta 25.2.0.
Here's the script:
getOverlay();
function getOverlay(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var desc = executeActionGet(ref);
if(!desc.hasKey(stringIDToTypeID( 'layerEffects' ))) {
return undefined;
}
if(!desc.getBoolean (stringIDToTypeID( 'layerFXVisible'))) {
return undefined;
}
desc = desc.getObjectValue(stringIDToTypeID('layerEffects'));
if(!desc.hasKey(stringIDToTypeID( 'solidFill'))) {
return undefined;
}
var desc = desc.getObjectValue(stringIDToTypeID('solidFill'));
var cColour = getColorFromDescriptor(desc.getObjectValue(stringIDToTypeID('color')), typeIDToCharID(desc.getClass(stringIDToTypeID('color'))));
return cColour.rgb.hexValue;
function getColorFromDescriptor(colorDesc, keyClass) {
var colorObject = new SolidColor();
switch (keyClass) {
case 'Grsc':
colorObject.grey.grey = color.getDouble(charIDToTypeID('Gry '));
break;
case 'RGBC':
colorObject.rgb.red = colorDesc.getDouble(charIDToTypeID('Rd '));
colorObject.rgb.green = colorDesc.getDouble(charIDToTypeID('Grn '));
colorObject.rgb.blue = colorDesc.getDouble(charIDToTypeID('Bl '));
break;
case 'CMYC':
colorObject.cmyk.cyan = colorDesc.getDouble(charIDToTypeID('Cyn '));
colorObject.cmyk.magenta = colorDesc.getDouble(charIDToTypeID('Mgnt'));
colorObject.cmyk.yellow = colorDesc.getDouble(charIDToTypeID('Ylw '));
colorObject.cmyk.black = colorDesc.getDouble(charIDToTypeID('Blck'));
break;
case 'LbCl':
colorObject.lab.l = colorDesc.getDouble(charIDToTypeID('Lmnc'));
colorObject.lab.a = colorDesc.getDouble(charIDToTypeID('A '));
colorObject.lab.b = colorDesc.getDouble(charIDToTypeID('B '));
break;
default:
return null;
}
return colorObject;
};
};
In prior Photoshop, for an RGB Color in a Color Overlay Layer Effect, this returns the hex code of the assigned color. In Beta 25.2.0, it returns:
- Error 8800: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
- The command “Get” is not currently available.
Line: 6
-> var desc = executeActionGet(ref);
I'm testing the Beta on MacOS 13.5.1 (22G90) on a 2018 Mac Mini Intel i7.
The steps to reproduce are:
create a new document
double-click "Background" layer in the Layers panel to make it a regular layer
double -click the layer to in the Layers panel again to bring up the Layer Styles box
click the checkbox for "Color Overlay" to add a color ocerlay layer effect
click "OK" to apply it
Run the javascript posted above (from ExtendScript Toolkit, or save as text file and use File->Scripts-Browse and select the script, or run from Applescript using "tell application "Photoshop" to do script"
I just tested this in Photoshop 2024 v25.4.0 and it works there. I also tried in Beta v25.5.0, and it worked there too. So whatever wasn't working in 25.2.0 seems to be fixed.
Copy link to clipboard
Copied
I just tested this in Photoshop 2024 v25.4.0 and it works there. I also tried in Beta v25.5.0, and it worked there too. So whatever wasn't working in 25.2.0 seems to be fixed.
Copy link to clipboard
Copied
I couldn't find a way to mark this as "resolved." I don't know if that requires an admin, or what. Let me know if there's something I can do.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more