Copy link to clipboard
Copied
Im not sure if i am in the correct place.
I need to know how to remove "color overlay" from layers using JavaScript.
I seen some forums that use something called an ActionReference or an ActionDescriptor... this is very complicated to me and makes no sense. I am not sure if ActionRefereneces or ActionDescriptors and the code i see is something that is generated in Adobe Photoshop after making some clicks. If it is then how does one go about using that feature?
either way, i wish to know how to access the properties and methods to remove "Color Overlays" using Adobe Photoshop JavaScript.
any help or guidance would be great.
thank you!
1 Correct answer
I only know of "standard, easy" DOM code to applyStyle and not to remove it.
I have given you the only three choices that I know of, the first only uses two lines of code, so would appear to be the simplest choice. The third version from the Clean SL script uses a named function, so you only need to use the function once then you can call it by name multipe times in multiple locations in your code.
You could answer your own question by trying the code yourself... But to answer your questio
...Explore related tutorials & articles
Copy link to clipboard
Copied
If I understand correctly, you would just like to change the Blend Modes from the layer to normal, if that is all, here is a script that does this.
#target photoshop
noColorOverlay();
function noColorOverlay() {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(app.charIDToTypeID('Lyr '), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));
desc1.putReference(app.charIDToTypeID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putEnumerated(app.charIDToTypeID('Md '), app.charIDToTypeID('BlnM'), app.charIDToTypeID('Nrml'));
desc1.putObject(app.charIDToTypeID('T '), app.charIDToTypeID('Lyr '), desc2);
executeAction(app.charIDToTypeID('setd'), desc1, DialogModes.NO);
};
Copy link to clipboard
Copied
Actually its not a "blending mode" its an effect or FX.
in the "Layers" panel, at the bottom theres an "FX" button, when you click FX button, theres "Color Overlay" option.
For example, when you apply this "Layers > FX > Color Overlay" to a "TEXT" layer, it changes the color of the Text.
and it also applies an "Effects" to the layer as you can see in the screenshot below. I want to remove that "effect" aka "Layer Style" using Javascript or if theres no resolution to do the task in Javascript then an ActionDescriptor
Copy link to clipboard
Copied
ScriptingListener plug-in recording of inserting the menu item into an action:
var iddisableLayerStyle = stringIDToTypeID( "disableLayerStyle" );
executeAction( iddisableLayerStyle, undefined, DialogModes.NO );
ScriptingListener plug-in recording of running the menu command:
var iddisableLayerStyle = stringIDToTypeID( "disableLayerStyle" );
var desc260 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref65 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref65.putEnumerated( idLyr, idOrdn, idTrgt );
desc260.putReference( idnull, ref65 );
executeAction( iddisableLayerStyle, desc260, DialogModes.NO );
Previous code passed through the "Clean SL" script to tidy it up and create a named function:
disableLayerStyle();
function disableLayerStyle() {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( c2t( "null" ), reference );
executeAction( s2t( "disableLayerStyle" ), descriptor, DialogModes.NO );
}
Enjoy!
P.S. Somebody else with more knowledge than me can show how to write this directly/concisely in ActionManager/ActionDescriptor code.
Copy link to clipboard
Copied
thank you for your response. the actionReferencer is a bit difficult for me. Is there a simplier JavasScript way or removing the color overlay style.. also.. sometimes some layers have more than one layer effect/style applied. i would just want to target color overlays effects and remove it and leave the other attached effects as is.. Will the code above work in that manner?
Copy link to clipboard
Copied
I only know of "standard, easy" DOM code to applyStyle and not to remove it.
I have given you the only three choices that I know of, the first only uses two lines of code, so would appear to be the simplest choice. The third version from the Clean SL script uses a named function, so you only need to use the function once then you can call it by name multipe times in multiple locations in your code.
You could answer your own question by trying the code yourself... But to answer your question, no, it removes all layer styles.
Offhand, to only remove the Color Overlay style leaving other styles intact:
var iddsfx = charIDToTypeID( "dsfx" );
var desc316 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref84 = new ActionReference();
var idSoFi = charIDToTypeID( "SoFi" );
ref84.putIndex( idSoFi, 1 );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref84.putEnumerated( idLyr, idOrdn, idTrgt );
desc316.putReference( idnull, ref84 );
executeAction( iddsfx, desc316, DialogModes.NO );
or
removeColorOverlayFX();
function removeColorOverlayFX() {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
reference.putIndex( s2t( "solidFill" ), 1 );
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( c2t( "null" ), reference );
executeAction( s2t( "disableSingleFX" ), descriptor, DialogModes.NO );
}
Be thankful that we have the ScriptingListener plugin, Clean SL etc. Without these options we would be stuffed.
Copy link to clipboard
Copied
Hey, thank you so much for all your help. your amazing!
ill give that last function a try and see if it works. i have to put that function in a recursive function so that it scans the whole document and checks all its layers and finds all those color overlay effects attached and then use that function to remove it. thanks once again i now have something to work with
Copy link to clipboard
Copied
Thanks, I'm just a beginner, all I do is record AM code and regurgitate it and sometimes change fixed values for variables etc. Basic stuff. There are others here that work true magic with the AM code, I'm sure that they could offer more concise code. The good news is that AM code generally runs fast, even if it looks verbose and complex.
In my limited tests, even if the function is applied to a layer without the color overlay style applied, there is no error returned. This means that you may not need to test whether a layer has the style applied first, you may just get away with looping over all layers and into all sets and nested sets/layers and remove the style, which may save some time (do test this though).
To contribute back to the community, it would be greatly appreciated if you could update this topic with your final recursive code.

