• 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 use Magic Wand tool in Photoshop scripting?

Community Beginner ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

I am trying to remove the image background using Scripting, I am stuck at the first step. I can't find a way to use Magic Wand tool using scripting in Javascript.

TOPICS
Actions and scripting , SDK , Windows

Views

2.1K

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

Community Expert , Sep 23, 2019 Sep 23, 2019

What you want to do may not be easy; however, using the magic wand tool is. Just use scriptListener to record using the magic wand tool, then just exchange variables for all the values that you normally set like tolerance, and put in the points where you want the magic wand to sample.

 

function quickSel (x, y, tol){
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChn
...

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

What you want to do may not be easy; however, using the magic wand tool is. Just use scriptListener to record using the magic wand tool, then just exchange variables for all the values that you normally set like tolerance, and put in the points where you want the magic wand to sample.

 

function quickSel (x, y, tol){
var idsetd = charIDToTypeID( "setd" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID( "Chnl" );
        var idfsel = charIDToTypeID( "fsel" );
        ref1.putProperty( idChnl, idfsel );
    desc2.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var desc3 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc3.putUnitDouble( idHrzn, idPxl, x );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc3.putUnitDouble( idVrtc, idPxl, y);
    var idPnt = charIDToTypeID( "Pnt " );
    desc2.putObject( idT, idPnt, desc3 );
    var idTlrn = charIDToTypeID( "Tlrn" );
    desc2.putInteger( idTlrn, tol);
    var idAntA = charIDToTypeID( "AntA" );
    desc2.putBoolean( idAntA, true );
    var idCntg = charIDToTypeID( "Cntg" );
    desc2.putBoolean( idCntg, true );
executeAction( idsetd, desc2, DialogModes.NO );
};

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
Community Beginner ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

LATEST
Thanks, This works

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