Copy link to clipboard
Copied
Hello,
I need a javascript to create a new art layer posterize in order to reduce the weight of my png.
But my javascript command does'nt work:
var LayerISO = app.activeDocument.artLayers.posterize.add(50);
Can someone help me?
Thanks.
1 Correct answer
You can do 2 ways… Using the DOM or scriptlistener…
#target photoshop
var doc = app.activeDocument.artLayers[0].posterize( 50 );
//posterizeLayer( 50 );
function posterizeLayer( numb ) {
function cTID(s) { return app.charIDToTypeID(s); };
//function sTID(s) { return app.stringIDToTypeID(s); };
var desc66 = new ActionDescriptor();
desc66.putInteger( cTID( 'Lvls' ), numb );
executeAction( cTID( 'Pstr' ), desc66, DialogModes.NO );
};
artLayers is an Array so target the one you
...Explore related tutorials & articles
Copy link to clipboard
Copied
You can do 2 ways… Using the DOM or scriptlistener…
#target photoshop
var doc = app.activeDocument.artLayers[0].posterize( 50 );
//posterizeLayer( 50 );
function posterizeLayer( numb ) {
function cTID(s) { return app.charIDToTypeID(s); };
//function sTID(s) { return app.stringIDToTypeID(s); };
var desc66 = new ActionDescriptor();
desc66.putInteger( cTID( 'Lvls' ), numb );
executeAction( cTID( 'Pstr' ), desc66, DialogModes.NO );
};
artLayers is an Array so target the one you want by index… No need for the .add()
Copy link to clipboard
Copied
You awesome Muppet MarK!
Thank you !
Copy link to clipboard
Copied
And ur mad it's a one liner...! (DOM)
You were close but no cigar...!
Sent from my iPhone

