0

我刚开始使用 JS 到 Photoshop。我需要在 as 之间对齐 2 层或更多层?例如 - 在顶部。每一层都有一个比图像小的蒙版。使用 Photoshop 菜单,我可以只对齐图像,而不对齐蒙版。我想对齐蒙版上的图像 - 通过蒙版可见到同一级别的图像。谢谢 !

4

1 回答 1

0

mm如果要转换图层(或图层蒙版),请使用这三个功能。你没有提到你使用的是什么版本的PS。

  • selectmask - 选择图层中的图层蒙版作为活动
  • linkUnlinkLayermask - 将图层蒙版链接或取消链接到它的图层
  • transformLayerLayer - 将图层(或图层蒙版)偏移多个像素

您应该能够根据需要操作图层并对齐它们。

//pref pixels
app.preferences.rulerUnits = Units.PIXELS;

var deltaX = 0
var deltaY = 20

selectMask("Layer 1")
linkUnlinkLayermask(false)
transformLayer(deltaX, deltaY)

function transformLayer(moveX, moveY)
{
    var id442 = charIDToTypeID( "Trnf" );
    var desc93 = new ActionDescriptor();
    var id443 = charIDToTypeID( "null" );
    var ref64 = new ActionReference();
    var id444 = charIDToTypeID( "Lyr " );
    var id445 = charIDToTypeID( "Ordn" );
    var id446 = charIDToTypeID( "Trgt" );
    ref64.putEnumerated( id444, id445, id446 );
    desc93.putReference( id443, ref64 );
    var id447 = charIDToTypeID( "FTcs" );
    var id448 = charIDToTypeID( "QCSt" );
    var id449 = charIDToTypeID( "Qcsa" );
    desc93.putEnumerated( id447, id448, id449 );
    var id450 = charIDToTypeID( "Ofst" );
    var desc94 = new ActionDescriptor();
    var id451 = charIDToTypeID( "Hrzn" );
    var id452 = charIDToTypeID( "#Pxl" );
    desc94.putUnitDouble( id451, id452, deltaX );
    var id453 = charIDToTypeID( "Vrtc" );
    var id454 = charIDToTypeID( "#Pxl" );
    desc94.putUnitDouble( id453, id454, deltaY );
    var id455 = charIDToTypeID( "Ofst" );
    desc93.putObject( id450, id455, desc94 );
    executeAction( id442, desc93, DialogModes.NO );
}

function selectMask(LayerName)
{
    var id2380 = charIDToTypeID( "slct" );
    var desc475 = new ActionDescriptor();
    var id2381 = charIDToTypeID( "null" );
    var ref352 = new ActionReference();
    var id2382 = charIDToTypeID( "Chnl" );
    var id2383 = charIDToTypeID( "Chnl" );
    var id2384 = charIDToTypeID( "Msk " );
    ref352.putEnumerated( id2382, id2383, id2384 );
    var id2385 = charIDToTypeID( "Lyr " );
    ref352.putName( id2385, LayerName );
    desc475.putReference( id2381, ref352 );
    var id2386 = charIDToTypeID( "MkVs" );
    desc475.putBoolean( id2386, false );
    executeAction( id2380, desc475, DialogModes.NO );
}

    function linkUnlinkLayermask(bool)
{
    var id2415 = charIDToTypeID( "setd" );
    var desc483 = new ActionDescriptor();
    var id2416 = charIDToTypeID( "null" );
    var ref359 = new ActionReference();
    var id2417 = charIDToTypeID( "Lyr " );
    var id2418 = charIDToTypeID( "Ordn" );
    var id2419 = charIDToTypeID( "Trgt" );
    ref359.putEnumerated( id2417, id2418, id2419 );
    desc483.putReference( id2416, ref359 );
    var id2420 = charIDToTypeID( "T   " );
    var desc484 = new ActionDescriptor();
    var id2421 = charIDToTypeID( "Usrs" );
    desc484.putBoolean( id2421, bool );
    var id2422 = charIDToTypeID( "Lyr " );
    desc483.putObject( id2420, id2422, desc484 );
    executeAction( id2415, desc483, DialogModes.NO );
}
于 2013-04-15T16:26:07.287 回答