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

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

New Here ,
Jul 25, 2014 Jul 25, 2014

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.

TOPICS
Actions and scripting

Views

474

Translate

Translate

Report

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

...

Votes

Translate

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

You awesome Muppet MarK!

Thank you !

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

You were close but no cigar...!

Sent from my iPhone

Votes

Translate

Translate

Report

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