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

How to add an art layer posterize levels 50 with javascript?

New Here ,
Jul 25, 2014 Jul 25, 2014

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.

TOPICS
Actions and scripting
604
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

Guru , Jul 25, 2014 Jul 25, 2014

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

...
Translate
Adobe
Guru ,
Jul 25, 2014 Jul 25, 2014

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()

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
New Here ,
Jul 25, 2014 Jul 25, 2014

You awesome Muppet MarK!

Thank you !

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
Guru ,
Jul 25, 2014 Jul 25, 2014
LATEST

And ur mad it's a one liner...! (DOM)

You were close but no cigar...!

Sent from my iPhone

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