Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Photoshop JavaScript Scripting - How to remove color overlay

Explorer ,
Jan 14, 2021 Jan 14, 2021

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!

TOPICS
Actions and scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 14, 2021 Jan 14, 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 questio

...
Translate
Adobe
Engaged ,
Jan 14, 2021 Jan 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);
};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2021 Jan 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.

screenshot.gifexpand image

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

screenshot-2.gifexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2021 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 14, 2021 Jan 14, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2021 Jan 14, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2021 Jan 15, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2021 Jan 15, 2021
LATEST

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.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines