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

how resize layer with a big image on size of layer mask ?

Participant ,
Jun 24, 2014 Jun 24, 2014

Copy link to clipboard

Copied

Hi all

How to resize the image on the layer mask?

* document - doc.width, doc.height

* mask - activeLayer.bounds

* and how to take the coordinates in the image with the mask if the image is larger than the size of the document?

01.jpg

TOPICS
Actions and scripting

Views

919

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 , Jun 24, 2014 Jun 24, 2014

// 2014, use it at your own risk;

#target "photoshop-70.032"

if (app.documents.length > 0) {

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var layerDesc = executeActionGet(ref);

var layerMaskEnabled = layerDesc.getBoolean(stringIDToTypeID("userMaskEnabled"));

if (layerMaskEnabled == true) {

// =======================================================

var idsetd = charIDToTypeID( "setd" );

    var desc4 = new ActionDescriptor();

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 24, 2014 Jun 24, 2014

Copy link to clipboard

Copied

When you disable the Layer Mask you should get the bounds of the Layer’s pixel content.

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
Participant ,
Jun 24, 2014 Jun 24, 2014

Copy link to clipboard

Copied

mmm ...  how ?

02.jpg

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 Expert ,
Jun 24, 2014 Jun 24, 2014

Copy link to clipboard

Copied

// 2014, use it at your own risk;

#target "photoshop-70.032"

if (app.documents.length > 0) {

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );

var layerDesc = executeActionGet(ref);

var layerMaskEnabled = layerDesc.getBoolean(stringIDToTypeID("userMaskEnabled"));

if (layerMaskEnabled == true) {

// =======================================================

var idsetd = charIDToTypeID( "setd" );

    var desc4 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1 = new ActionReference();

        var idLyr = charIDToTypeID( "Lyr " );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref1.putEnumerated( idLyr, idOrdn, idTrgt );

    desc4.putReference( idnull, ref1 );

    var idT = charIDToTypeID( "T   " );

        var desc5 = new ActionDescriptor();

        var idUsrM = charIDToTypeID( "UsrM" );

        desc5.putBoolean( idUsrM, false );

    var idLyr = charIDToTypeID( "Lyr " );

    desc4.putObject( idT, idLyr, desc5 );

executeAction( idsetd, desc4, DialogModes.NO );

};

alert (app.activeDocument.activeLayer.bounds)

};

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
Participant ,
Jun 25, 2014 Jun 25, 2014

Copy link to clipboard

Copied

how resize mask or delete it ?

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 Expert ,
Jun 25, 2014 Jun 25, 2014

Copy link to clipboard

Copied

For deleting the Layer Mask I recommend recording Action Manager code with ScriptingListener.plugin

Resizing it should be possible in DOM by selecting it (as the sole content of an Array for activeDocument.activeChannels).

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
Participant ,
Jun 25, 2014 Jun 25, 2014

Copy link to clipboard

Copied

//For deleting the Layer Mask I recommend recording Action Manager code with ScriptingListener.plugin

I'm write script on delete LM in ScriptListener, but it not worked !

var idsetd = charIDToTypeID( "setd" );

  var desc162 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref125 = new ActionReference();

  var idLyr = charIDToTypeID( "Lyr " );

  var idOrdn = charIDToTypeID( "Ordn" );

  var idTrgt = charIDToTypeID( "Trgt" );

  ref125.putEnumerated( idLyr, idOrdn, idTrgt );

  desc162.putReference( idnull, ref125 );

  var idT = charIDToTypeID( "T " );

  var desc163 = new ActionDescriptor();

  var idUsrs = charIDToTypeID( "Usrs" );

  desc163.putBoolean( idUsrs, false );

  var idLyr = charIDToTypeID( "Lyr " );

  desc162.putObject( idT, idLyr, desc163 );

executeAction( idsetd, desc162, DialogModes.NO );

Resizing it should be possible in DOM by selecting it (as the sole content of an Array for activeDocument.activeChannels).

Please, help me to defined 4 variables (left, top, right and bottom)!

row 33, 36 - indent Hor and Vert

row 41, 44 ??? This is %%  !!!

// =======================================================

var idslct = charIDToTypeID( "slct" );

  var desc164 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref126 = new ActionReference();

  var idChnl = charIDToTypeID( "Chnl" );

  var idOrdn = charIDToTypeID( "Ordn" );

  var idTrgt = charIDToTypeID( "Trgt" );

  ref126.putEnumerated( idChnl, idOrdn, idTrgt );

  desc164.putReference( idnull, ref126 );

  var idMkVs = charIDToTypeID( "MkVs" );

  desc164.putBoolean( idMkVs, false );

executeAction( idslct, desc164, DialogModes.NO );

// =======================================================

var idTrnf = charIDToTypeID( "Trnf" );

  var desc165 = new ActionDescriptor();

  var idnull = charIDToTypeID( "null" );

  var ref127 = new ActionReference();

  var idLyr = charIDToTypeID( "Lyr " );

  var idOrdn = charIDToTypeID( "Ordn" );

  var idTrgt = charIDToTypeID( "Trgt" );

  ref127.putEnumerated( idLyr, idOrdn, idTrgt );

  desc165.putReference( idnull, ref127 );

  var idFTcs = charIDToTypeID( "FTcs" );

  var idQCSt = charIDToTypeID( "QCSt" );

  var idQcsa = charIDToTypeID( "Qcsa" );

  desc165.putEnumerated( idFTcs, idQCSt, idQcsa );

  var idOfst = charIDToTypeID( "Ofst" );

  var desc166 = new ActionDescriptor();

  var idHrzn = charIDToTypeID( "Hrzn" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc166.putUnitDouble( idHrzn, idPxl, 13.500000 );

  var idVrtc = charIDToTypeID( "Vrtc" );

  var idPxl = charIDToTypeID( "#Pxl" );

  desc166.putUnitDouble( idVrtc, idPxl, -6.500000 );

  var idOfst = charIDToTypeID( "Ofst" );

  desc165.putObject( idOfst, idOfst, desc166 );

  var idWdth = charIDToTypeID( "Wdth" );

  var idPrc = charIDToTypeID( "#Prc" );

  desc165.putUnitDouble( idWdth, idPrc, 125.064267 );

   var idHght = charIDToTypeID( "Hght" );             What is this ?&&&&

  var idPrc = charIDToTypeID( "#Prc" );

  desc165.putUnitDouble( idHght, idPrc, 135.227273 );

  var idIntr = charIDToTypeID( "Intr" );

  var idIntp = charIDToTypeID( "Intp" );

  var idBcbc = charIDToTypeID( "Bcbc" );

  desc165.putEnumerated( idIntr, idIntp, idBcbc );

executeAction( idTrnf, desc165, 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 Expert ,
Jun 27, 2014 Jun 27, 2014

Copy link to clipboard

Copied

LATEST

As for deleting a Layer Mask this would work on the active layer:

////// delete or apply layer mask //////

function deleteLayerMask (apply) {

if (apply == undefined) {var apply = false};

try {

// =======================================================

var idDlt = charIDToTypeID( "Dlt " );

    var desc9 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref5 = new ActionReference();

        var idChnl = charIDToTypeID( "Chnl" );

        var idChnl = charIDToTypeID( "Chnl" );

        var idMsk = charIDToTypeID( "Msk " );

        ref5.putEnumerated( idChnl, idChnl, idMsk );

    desc9.putReference( idnull, ref5 );

    var idAply = charIDToTypeID( "Aply" );

    desc9.putBoolean( idAply, apply );

executeAction( idDlt, desc9, DialogModes.NO );

}

catch (e) {}

};

As for the second part I am not sure what you want to achieve exactly.

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