Skip to main content
davidc88034496
Known Participant
January 14, 2021
Answered

Photoshop JavaScript Scripting - How to remove color overlay

  • January 14, 2021
  • 2 replies
  • 1457 views

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!

This topic has been closed for replies.
Correct answer Stephen Marsh

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.

2 replies

Stephen Marsh
Braniac
January 14, 2021

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 );
}

 

Clean SL

Clean-SL

Enjoy!

 

P.S. Somebody else with more knowledge than me can show how to write this directly/concisely in ActionManager/ActionDescriptor code.

davidc88034496
Known Participant
January 15, 2021

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?

Stephen Marsh
Stephen MarshCorrect answer
Braniac
January 15, 2021

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.

Shulipa Bernad
Inspiring
January 14, 2021

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);
};
davidc88034496
Known Participant
January 14, 2021

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