Copy link to clipboard
Copied
Hi community,
I'm looking for a way to select layers with the same styles.
Is there any solution?
Regards
Copy link to clipboard
Copied
Please elaborate.
What do you mean by »same« exactly?
The same Layer Style as in »all Layers with Drop Shadows« or the exact same settings in Drop Shadows?
How good are you with JavaScript and Photoshop’s AM code?
Copy link to clipboard
Copied
Thanks @c.pfaffenbichler
I have a file with too many layers. Some of them are with Blue color overlay, and I need to change the color to Red.
If there is a script that can be used please share.
Regards.
Copy link to clipboard
Copied
First off: I doubt there is an existing Script for this specific task, but maybe someone else knows better.
Secondly: Please elaborate properly.
Are there only blue Color Overlays, are there others, do only the blue ones need to be changed or not, do the blue ones have the exact same blue or do they vary, …?
Copy link to clipboard
Copied
Hey @c.pfaffenbichler
Each Blue object is in a separate layer (ungrouped), layer style (Color Overlay: 100cyan+100magenta).
I need to replace the color with (100magenta+100yellow).
Is it possible to group all similar layers with the same layer style and apply a new (Color Overlay)?
How can I change the Blue to Red without affecting the colors of other layers?
Regards
Copy link to clipboard
Copied
Sorry, I had some stress and couldn’t follow up and I am going to be on vacation for a few weeks now.
I would recommend that you start a new thread and provide a sample image right away and hopefully one of the Scripting-savvy regulars will provide advice.
Otherwise I might be able to get back to this sometime in november … good luck in any case!
Copy link to clipboard
Copied
Hope we find a solution soon
Copy link to clipboard
Copied
Try this. (edited 2022-11-14)
// change layer style color overlay of specific cmyk color to another color;
// 2022, use it at your own risk;
if (app.documents.length > 0) {
var oldColor = "100,100,0,0";
var newColor = [0,100,100,0];
var theLayers = collectLayersNamesIdentifierColorOverlay(newColor);
alert (theLayers.join("\n"));
};
////// collect layers //////
function collectLayersNamesIdentifierColorOverlay (newColor) {
// get number of layers;
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID('numberOfLayers'));
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
// process the layers;
var theLayers = new Array;
for (var m = 0; m <= theNumber; m++) {
try {
var ref = new ActionReference();
ref.putIndex( charIDToTypeID( "Lyr " ), m);
var layerDesc = executeActionGet(ref);
var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
// if group collect values;
if (layerSet != "layerSectionEnd" /*&& layerSet != "layerSectionStart" && isBackground != true*/) {
var theName = layerDesc.getString(stringIDToTypeID('name'));
var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
// get colors for color overlays;
try {
var effectsDesc = layerDesc.getObjectValue(stringIDToTypeID('layerEffects'));
var solid = effectsDesc.getObjectValue(stringIDToTypeID('solidFill'));
var theColors = solid.getObjectValue(stringIDToTypeID('color'));
var isEnabled = solid.getBoolean(charIDToTypeID( "enab" ));
var theOpacity = solid.getInteger(charIDToTypeID( "Opct" ));
var theBlendMode = solid.getEnumerationValue(stringIDToTypeID( "mode" ));
var str = new Array;
for(var i=0;i<theColors.count;i++){
str.push(theColors.getUnitDoubleValue(theColors.getKey(i)));
};
// change color overlay;
if (str.join(",") == "100,100,0,0") {
// collect layers;
theLayers.push([theName, theID, str]);
var idsetd = charIDToTypeID( "setd" );
var desc13 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref2.putProperty( idPrpr, idLefx );
ref2.putIdentifier(charIDToTypeID( "Lyr " ), theID);
desc13.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc14 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc14.putUnitDouble( idScl, idPrc, 100.000000 );
var idSoFi = charIDToTypeID( "SoFi" );
var desc15 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc15.putBoolean( idenab, isEnabled );
var idpresent = stringIDToTypeID( "present" );
desc15.putBoolean( idpresent, true );
var idshowInDialog = stringIDToTypeID( "showInDialog" );
desc15.putBoolean( idshowInDialog, true );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
desc15.putEnumerated( idMd, idBlnM, theBlendMode );
var idClr = charIDToTypeID( "Clr " );
var desc16 = new ActionDescriptor();
desc16.putDouble( stringIDToTypeID( "cyan" ), newColor[0] );
desc16.putDouble( stringIDToTypeID( "magenta" ), newColor[1] );
desc16.putDouble( stringIDToTypeID( "yellow" ), newColor[2] );
desc16.putDouble( stringIDToTypeID( "black" ), newColor[3] );
desc15.putObject( idClr, stringIDToTypeID( "CMYKColorClass" ), desc16 );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc15.putUnitDouble( idOpct, idPrc, theOpacity );
var idSoFi = charIDToTypeID( "SoFi" );
desc14.putObject( idSoFi, idSoFi, desc15 );
var idLefx = charIDToTypeID( "Lefx" );
desc13.putObject( idT, idLefx, desc14 );
executeAction( idsetd, desc13, DialogModes.NO );
};
//
} catch (e) {};
};
}
catch (e) {};
};
return theLayers
};