Copy link to clipboard
Copied
// =======================================================
var id11 = charIDToTypeID( "slct" );
var desc6 = new ActionDescriptor();
var id12 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id13 = charIDToTypeID( "Lyr " );
ref1.putName( id13, "photoframe" );
desc6.putReference( id12, ref1 );
var id14 = charIDToTypeID( "MkVs" );
desc6.putBoolean( id14, false );
executeAction( id11, desc6, DialogModes.NO );
// =======================================================
var id15 = charIDToTypeID( "slct" );
var desc7 = new ActionDescriptor();
var id16 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id17 = charIDToTypeID( "Dcmn" );
ref2.putOffset( id17, -4 );
desc7.putReference( id16, ref2 );
executeAction( id15, desc7, DialogModes.NO );
// =======================================================
var id18 = charIDToTypeID( "setd" );
var desc8 = new ActionDescriptor();
var id19 = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var id20 = charIDToTypeID( "Chnl" );
var id21 = charIDToTypeID( "fsel" );
ref3.putProperty( id20, id21 );
desc8.putReference( id19, ref3 );
var id22 = charIDToTypeID( "T " );
var id23 = charIDToTypeID( "Ordn" );
var id24 = charIDToTypeID( "Al " );
desc8.putEnumerated( id22, id23, id24 );
executeAction( id18, desc8, DialogModes.NO );
// =======================================================
var id25 = charIDToTypeID( "cut " );
executeAction( id25, undefined, DialogModes.NO );
// =======================================================
var id26 = charIDToTypeID( "Cls " );
var desc9 = new ActionDescriptor();
var id27 = charIDToTypeID( "Svng" );
var id28 = charIDToTypeID( "YsN " );
var id29 = charIDToTypeID( "N " );
desc9.putEnumerated( id27, id28, id29 );
executeAction( id26, desc9, DialogModes.NO );
// =======================================================
var id30 = charIDToTypeID( "past" );
var desc10 = new ActionDescriptor();
var id31 = charIDToTypeID( "AntA" );
var id32 = charIDToTypeID( "Annt" );
var id33 = charIDToTypeID( "Anno" );
desc10.putEnumerated( id31, id32, id33 );
executeAction( id30, desc10, DialogModes.NO );
createSmartObject(app.activeDocument.activeLayer);
function createSmartObject(layer)
{
var idnewPlacedLayer = stringIDToTypeID( 'newPlacedLayer' );
executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
}
var oldPref = app.preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS;
var doc = activeDocument;
var iLayer = doc.activeLayer;
layerDown ();
var mLayerB = doc.activeLayer.bounds;
doc.activeLayer = iLayer;
var scale = Math.max((mLayerB[2]-mLayerB[0])/(iLayer.bounds[2]-iLayer.bounds[0]),(mLayerB[3]-mLayerB[1])/(iLayer.bounds[3]-iLayer.bounds[1]));
iLayer.resize (scale*100,scale*100);
iLayer.translate((mLayerB[0]+mLayerB[2])/2-(iLayer.bounds[0]+iLayer.bounds[2])/2,(mLayerB[1]+mLayerB[3])/2-(iLayer.bounds[1]+iLayer.bounds[3])/2);
clip ();
function clip(){
var idGrpL = charIDToTypeID( "GrpL" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref6 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref6.putEnumerated( idLyr, idOrdn, idTrgt );
desc7.putReference( idnull, ref6 );
executeAction( idGrpL, desc7, DialogModes.NO );
};
function layerDown(){
var idslct = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idBckw = charIDToTypeID( "Bckw" );
ref1.putEnumerated( idLyr, idOrdn, idBckw );
desc2.putReference( idnull, ref1 );
var idMkVs = charIDToTypeID( "MkVs" );
desc2.putBoolean( idMkVs, false );
var idLyrI = charIDToTypeID( "LyrI" );
var list1 = new ActionList();
list1.putInteger( 3 );
desc2.putList( idLyrI, list1 );
executeAction( idslct, desc2, DialogModes.NO );
};
var id3 = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var id4 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id5 = charIDToTypeID( "Lyr " );
var id6 = charIDToTypeID( "Ordn" );
var id7 = charIDToTypeID( "Bckw" );
ref1.putEnumerated( id5, id6, id7 );
desc2.putReference( id4, ref1 );
var id8 = charIDToTypeID( "MkVs" );
desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );
// =======================================================
var id9 = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var id10 = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var id11 = charIDToTypeID( "Lyr " );
var id12 = charIDToTypeID( "Ordn" );
var id13 = charIDToTypeID( "Trgt" );
ref2.putEnumerated( id11, id12, id13 );
desc3.putReference( id10, ref2 );
var id14 = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var id15 = charIDToTypeID( "Nm " );
desc4.putString( id15, "photoframe" );
var id16 = charIDToTypeID( "Lyr " );
desc3.putObject( id14, id16, desc4 );
executeAction( id9, desc3, DialogModes.NO );
var id3 = charIDToTypeID( "slct" );
var desc2 = new ActionDescriptor();
var id4 = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var id5 = charIDToTypeID( "Lyr " );
var id6 = charIDToTypeID( "Ordn" );
var id7 = charIDToTypeID( "Frwr" );
ref1.putEnumerated( id5, id6, id7 );
desc2.putReference( id4, ref1 );
var id8 = charIDToTypeID( "MkVs" );
desc2.putBoolean( id8, false );
executeAction( id3, desc2, DialogModes.NO );
var id331 = charIDToTypeID( "setd" );
var desc68 = new ActionDescriptor();
var id332 = charIDToTypeID( "null" );
var ref40 = new ActionReference();
var id333 = charIDToTypeID( "Lyr " );
var id334 = charIDToTypeID( "Ordn" );
var id335 = charIDToTypeID( "Trgt" );
ref40.putEnumerated( id333, id334, id335 );
desc68.putReference( id332, ref40 );
var id336 = charIDToTypeID( "T " );
var desc69 = new ActionDescriptor();
var id337 = charIDToTypeID( "Nm " );
desc69.putString( id337, "IMAGE LAYER" );
var id338 = charIDToTypeID( "Lyr " );
desc68.putObject( id336, id338, desc69 );
executeAction( id331, desc68, DialogModes.NO );
Copy link to clipboard
Copied
Do you have a specific issue related to this script?
Copy link to clipboard
Copied
Please post a description and screenshots to illustrate/clarify the process you want to automate.