Photoshop的JS脚本来创建和应用图层蒙版 [英] Photoshop JS script to create and apply a layer mask

查看:298
本文介绍了Photoshop的JS脚本来创建和应用图层蒙版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在JS Photoshop的脚本,需要每一层文件夹和空格它像一个精灵表。我已经想通了,一部分,但我试图运行脚本的同时,以消除任何形式的人为错误。现在,你需要preP每一层文件夹的正确命名您的文件,你也有一个图层蒙版应用于选择。

我想删除的需要为用户应用层掩模。我可以选择图层,然后选择我要掩盖的部分,但我对如何应用或创建蒙毫无头绪。

在哪里,我希望它可以应用于:

 函数maskIt(){
    如果(currentFrameCount≤(frameNumber的-1)){
        currentFrameCount = currentFrameCount + 1;
        设置currentFrame =(帧+ currentFrameCount);
        activeDocument.layers [设置currentFrame] .visable;
        activeDocument.selection.selectAll();
        // createMask();
        maskComplete = FALSE;
    }否则如果(currentFrameCount ==(frameNumber的-1)){
        currentFrameCount = currentFrameCount + 1;
        设置currentFrame =(帧+ currentFrameCount);
        activeDocument.layers [设置currentFrame] .visable;
        activeDocument.selection.selectAll();
        // createMask();
        currentFrameCount = 0;
        maskComplete = TRUE;
    }
}


解决方案

从scriptlistener收拾这两个功能可以帮助你:

  //函数做面膜()
功能makeMask()
{
  // ================================================ =======
  变种id4556 = charIDToTypeID(SETD);
  VAR desc983 =新ActionDescriptor();
  变种id4557 = charIDToTypeID(空);
  VAR ref657 =新ActionReference();
  变种id4558 = charIDToTypeID(CHNL);
  变种id4559 = charIDToTypeID(FSEL);
  ref657.putProperty(id4558,id4559);
  desc983.putReference(id4557,ref657);
  VAR id4560 = charIDToTypeID(T);
  VAR ref658 =新ActionReference();
  变种id4561 = charIDToTypeID(CHNL);
  变种id4562 = charIDToTypeID(CHNL);
  变种id4563 = charIDToTypeID(Trsp);
  ref658.putEnumerated(id4561,id4562,id4563);
  desc983.putReference(id4560,ref658);
  executeAction(id4556,desc983,DialogModes.NO);  // ================================================ =======
  变种id4564 = charIDToTypeID(的Mk);
  VAR desc984 =新ActionDescriptor();
  变种id4565 = charIDToTypeID(NW);
  变种id4566 = charIDToTypeID(CHNL);
  desc984.putClass(id4565,id4566);
  变种id4567 = charIDToTypeID(AT);
  VAR ref659 =新ActionReference();
  变种id4568 = charIDToTypeID(CHNL);
  变种id4569 = charIDToTypeID(CHNL);
  变种id4570 = charIDToTypeID(Msk高);
  ref659.putEnumerated(id4568,id4569,id4570);
  desc984.putReference(id4567,ref659);
  变种id4571 = charIDToTypeID(USNG);
  变种id4572 = charIDToTypeID(USRM);
  变种id4573 = charIDToTypeID(RvlS);
  desc984.putEnumerated(id4571,id4572,id4573);
  executeAction(id4564,desc984,DialogModes.NO);
}
//函数应用于图层蒙版()
功能applyLayerMask()
{
  // ================================================ =======
  变种id1949 = charIDToTypeID(DLT);
  VAR desc398 =新ActionDescriptor();
  变种id1950 = charIDToTypeID(空);
  VAR ref291 =新ActionReference();
  变种id1951 = charIDToTypeID(CHNL);
  变种id1952 = charIDToTypeID(CHNL);
  变种id1953 = charIDToTypeID(Msk高);
  ref291.putEnumerated(id1951,id1952,id1953);
  desc398.putReference(id1950,ref291);
  变种id1954 = charIDToTypeID(APLY);
  desc398.putBoolean(id1954,真);
  executeAction(id1949,desc398,DialogModes.NO);
}

如果你想排除用户错误的人,你可能需要第三个功能,将检测层是否具有作为面膜或没有(选择层,试图复制并粘贴图层蒙版;如果它不膏 - 无图层蒙版)

I wrote a Photoshop script in JS that takes each layer folder and spaces it out like a sprite sheet. I've figured out that part, but I'm trying to remove any form of human error while running the script. Right now, you need to prep your file with the correct naming of each layer folder, and you also have to apply a layer mask to the selection.

I want to remove the need for the user to apply a layer mask. I can select the layer, and then select the portion I want to mask, but I have no clue on how to apply or create the mask.

Where I want it to be applied:

function maskIt(){
    if(currentFrameCount < (frameNumber-1)){
        currentFrameCount = currentFrameCount+1;
        currentFrame = ("frame"+currentFrameCount);
        activeDocument.layers[currentFrame].visable;
        activeDocument.selection.selectAll();
        //createMask();
        maskComplete = false;
    } else  if (currentFrameCount == (frameNumber-1)){
        currentFrameCount = currentFrameCount+1;
        currentFrame = ("frame"+currentFrameCount);
        activeDocument.layers[currentFrame].visable;
        activeDocument.selection.selectAll();
        //createMask();
        currentFrameCount = 0;
        maskComplete = true;
    }
}

解决方案

These two functions tidied up from the scriptlistener should help you:

// FUNCTION MAKE MASK ()
function makeMask()
{
  // =======================================================
  var id4556 = charIDToTypeID( "setd" );
  var desc983 = new ActionDescriptor();
  var id4557 = charIDToTypeID( "null" );
  var ref657 = new ActionReference();
  var id4558 = charIDToTypeID( "Chnl" );
  var id4559 = charIDToTypeID( "fsel" );
  ref657.putProperty( id4558, id4559 );
  desc983.putReference( id4557, ref657 );
  var id4560 = charIDToTypeID( "T   " );
  var ref658 = new ActionReference();
  var id4561 = charIDToTypeID( "Chnl" );
  var id4562 = charIDToTypeID( "Chnl" );
  var id4563 = charIDToTypeID( "Trsp" );
  ref658.putEnumerated( id4561, id4562, id4563 );
  desc983.putReference( id4560, ref658 );
  executeAction( id4556, desc983, DialogModes.NO );

  // =======================================================
  var id4564 = charIDToTypeID( "Mk  " );
  var desc984 = new ActionDescriptor();
  var id4565 = charIDToTypeID( "Nw  " );
  var id4566 = charIDToTypeID( "Chnl" );
  desc984.putClass( id4565, id4566 );
  var id4567 = charIDToTypeID( "At  " );
  var ref659 = new ActionReference();
  var id4568 = charIDToTypeID( "Chnl" );
  var id4569 = charIDToTypeID( "Chnl" );
  var id4570 = charIDToTypeID( "Msk " );
  ref659.putEnumerated( id4568, id4569, id4570 );
  desc984.putReference( id4567, ref659 );
  var id4571 = charIDToTypeID( "Usng" );
  var id4572 = charIDToTypeID( "UsrM" );
  var id4573 = charIDToTypeID( "RvlS" );
  desc984.putEnumerated( id4571, id4572, id4573 );
  executeAction( id4564, desc984, DialogModes.NO );
}


// FUNCTION APPLY LAYER MASK()
function applyLayerMask()
{
  // =======================================================
  var id1949 = charIDToTypeID( "Dlt " );
  var desc398 = new ActionDescriptor();
  var id1950 = charIDToTypeID( "null" );
  var ref291 = new ActionReference();
  var id1951 = charIDToTypeID( "Chnl" );
  var id1952 = charIDToTypeID( "Chnl" );
  var id1953 = charIDToTypeID( "Msk " );
  ref291.putEnumerated( id1951, id1952, id1953 );
  desc398.putReference( id1950, ref291 );
  var id1954 = charIDToTypeID( "Aply" );
  desc398.putBoolean( id1954, true );
  executeAction( id1949, desc398, DialogModes.NO );
}

If you are trying to rule out user error human you may need a third function which will detect whether a layer has as mask on or not (Select that layer, try to copy and paste the layer mask; if it doesn't paste - no layer mask)

这篇关于Photoshop的JS脚本来创建和应用图层蒙版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆