PHOTOSHOP_TEMPLATES
=======================Blank_Document_Template=========================
#target photoshop // Document_Blank
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
//WaitForRedraw() ; alert ( "preferences saved")
//==================================================================
var docRef = app.documents.add(220, 240, 72, "NewDocument", NewDocumentMode.RGB, DocumentFill.WHITE);
WaitForRedraw() ; alert ( "create White RBG document");
//==================================================================
var w = docRef.height
var h = docRef.width
var r = docRef.resolution
var n = docRef.name ; // alert ( "w="+w+" h="+h+" r="+r+" n="+n);
var m = docRef.mode ; // alert ( m); // DocumentMode.RGB
var p = docRef.pixelAspectRatio ; // alert ( p); // 1
var b = docRef.bitsPerChannel ; // alert ( b); // BitsPerChannelType.EIGHT
var bl = docRef.backgroundLayer ; // alert ( bl); // [Artlayer Background]
var al = docRef.activeLayer ; // alert ( al); // [Artlayer Background]
var l = docRef.layers ; // alert ( l); // [Layers]
var c = docRef.activeChannels ; // alert ( c ); // [Channel Red],[Channel Green],[Channel Blue]
WaitForRedraw() ; alert ( "Get Document Info \r w="+w+" h="+h+" r="+r+" n="+n);
//==================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 0; colorRef.rgb.green= 255; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "foregroundColor set");
//==================================================================
colorRef.rgb.red = 255; colorRef.rgb.green= 255; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "backgroundColor set");
//==================================================================
docRef.selection.selectAll; //app.activeDocument.selection.selectAll ;
WaitForRedraw() ; alert ( "selectAll set " )
colorRef.rgb.red = 255; colorRef.rgb.green= 100; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.activeDocument.selection.fill( colorRef) ;
WaitForRedraw() ; alert ( "Selection filled \r")
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=======================Open_File==============================
#target photoshop // File Open
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
WaitForRedraw() ; alert ( "preferences saved")
//==================================================================
var fileName = app.path.toString() + "/Samples/Dune.tif";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Open File " + fileName)
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=======================File_Open_Template==============================
#target photoshop // File Open
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
WaitForRedraw() ; alert ( "preferences saved")
//==================================================================
var fileName = "/Users/don_sauer/Desktop/Tiger.jpg";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Open File " + fileName)
//==================================================================
var w = docRef.height
var h = docRef.width
var r = docRef.resolution
var n = docRef.name ; // alert ( "w="+w+" h="+h+" r="+r+" n="+n);
var m = docRef.mode ; // alert ( m); // DocumentMode.RGB
var p = docRef.pixelAspectRatio ; // alert ( p); // 1
var b = docRef.bitsPerChannel ; // alert ( b); // BitsPerChannelType.EIGHT
var bl = docRef.backgroundLayer ; // alert ( bl); // [Artlayer Background]
var al = docRef.activeLayer ; // alert ( al); // [Artlayer Background]
var l = docRef.layers ; // alert ( l); // [Layers]
var c = docRef.activeChannels ; // alert ( c ); // [Channel Red],[Channel Green],[Channel Blue]
WaitForRedraw() ; alert ( "Get Document Info \r w="+w+" h="+h+" r="+r+" n="+n);
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
========================PRINT_LAYERS===============================
var docRef = app.activeDocument;
temp = new File( "/Users/don_sauer/Downloads/myfilelayers" );
temp.open( 'e' ); // e for edit
temp.encoding = 'US-ASCII';
var layerslist ="layerslist[]= \r"
for (var i= 0; i < docRef.layers.length ; i++)
{ layerslist = layerslist+i+" "+ docRef.layers[i].name +" \r";
}
temp.writeln(layerslist);
temp.close();
=======================PRINT_FONTS==============================
var docRef = app.activeDocument;
temp = new File( "/Users/don_sauer/Downloads/myfileFonts" );
temp.open( 'e' ); // e for edit
temp.encoding = 'US-ASCII';
var fontlist ="layerslist[]= \r"
for (var i= 0; i < app.fonts.length ; i++)
{ fontlist = fontlist +i+" "+ app.fonts[i].name +" \r";
}
temp.writeln(fontlist);
temp.close();
=======================Document_Templates==============================
#target photoshop // Document_Tutorials
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var docRef = app.documents.add(320, 240, 72, "NewDocument", NewDocumentMode.RGB, DocumentFill.WHITE);
var w = docRef.height
var h = docRef.width
var r = docRef.resolution
var n = docRef.name ; // alert ( "w="+w+" h="+h+" r="+r+" n="+n);
var m = docRef.mode ; // alert ( m); // DocumentMode.RGB
var p = docRef.pixelAspectRatio ; // alert ( p); // 1
var b = docRef.bitsPerChannel ; // alert ( b); // BitsPerChannelType.EIGHT
var bl = docRef.backgroundLayer ; // alert ( bl); // [Artlayer Background]
var al = docRef.activeLayer ; // alert ( al); // [Artlayer Background]
var l = docRef.layers ; // alert ( l); // [Layers]
var c = docRef.activeChannels ; // alert ( c ); // [Channel Red],[Channel Green],[Channel Blue]
WaitForRedraw() ; alert ( "create a document \r w="+w+" h="+h+" r="+r+" n="+n);
//=================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 0
colorRef.rgb.green = 255
colorRef.rgb.blue = 0
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "set foregroundColor \r"+colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue);
//=================================================================
colorRef.rgb.red = 255
colorRef.rgb.green = 255
colorRef.rgb.blue = 0
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "set backgroundColor \r"+colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue);
//=================================================================
docRef.selection.selectAll; //app.activeDocument.selection.selectAll ;
WaitForRedraw() ; alert ( "selectAll " )
colorRef.rgb.red = 255
colorRef.rgb.green = 100
colorRef.rgb.blue = 0
app.activeDocument.selection.fill(colorRef) ;
WaitForRedraw() ; alert ( "fill orange \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
//=================================================================
var selBounds1 = Array( Array(50, 50),
Array(200, 50),
Array(200, 200),
Array(50, 200) );
docRef.selection.select( selBounds1);
WaitForRedraw(); alert ( "selBounds1 \r"+ selBounds1 )
//=================================================================
docRef.selection.invert();
colorRef.rgb.red = 255
colorRef.rgb.green = 0
colorRef.rgb.blue = 255
WaitForRedraw() ; alert ( "inverted select" )
//=================================================================
app.activeDocument.selection.fill(colorRef) ;
WaitForRedraw() ; alert ( "fill select" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue )
var selRef = app.activeDocument.selection
selRef.contract( 5 ) ; //selRef.expand( 5 )
WaitForRedraw() ; alert ( "contracted select by 5" )
//=================================================================
colorRef.rgb.red = 155
colorRef.rgb.green = 0
colorRef.rgb.blue = 255
app.activeDocument.selection.fill(colorRef);
WaitForRedraw() ; alert ( "filled selection \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
//=================================================================
docRef.selection.invert();
docRef.selection.deselect();
WaitForRedraw() ; alert ( "deselect " )
//=================================================================
var selBounds2 = Array( Array(70, 70),
Array(100, 70),
Array(100, 100),
Array(70, 100) );
colorRef.rgb.red = 255
colorRef.rgb.green = 255
colorRef.rgb.blue = 0
docRef.selection.select( selBounds2);
WaitForRedraw() ; alert ( "selBounds2 \r" + selBounds2 )
//=================================================================
app.activeDocument.selection.stroke (colorRef, 5, StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75, false)
//=================================================================
WaitForRedraw() ; alert ( "stroke outside select \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue )
docRef.selection.deselect();
WaitForRedraw() ; alert ( "deselect_" )
//=================================================================
var selBounds3 = Array( Array(170, 70),
Array(200, 70),
Array(200, 100),
Array(170, 100) );
docRef.selection.select( selBounds3);
WaitForRedraw() ; alert ( "selBounds3 \r" + selBounds2 )
//=================================================================
app.activeDocument.selection.stroke (colorRef, 5, StrokeLocation.INSIDE, ColorBlendMode.VIVIDLIGHT, 75, false) //CENTER
WaitForRedraw() ; alert ( "stroke inside select" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue )
//=================================================================
docRef.selection.deselect();
WaitForRedraw() ; alert ( "deselect" )
docRef.flipCanvas( Direction.HORIZONTAL)
WaitForRedraw() ; alert ( "Flip_Horz" )
//=================================================================
docRef.flipCanvas( Direction.VERTICAL)
WaitForRedraw() ; alert ( "Flip_Vert" )
//=================================================================
docRef.resizeImage( 400,300 )
WaitForRedraw() ; alert ( "resize image 400x300" )
//=================================================================
docRef.crop ( new Array(10,20,240,250), 5, 320, 320 ) //boundsArray(left,top,right,bottom),angle,w,h
WaitForRedraw() ; alert ( "crop \r bounds =(10,20,240,250) angle=5 w=320 h=320" )
//=================================================================
app.activeDocument.rotateCanvas(45);
WaitForRedraw() ; alert ( "Rotate 45" )
//=================================================================
docRef.resizeCanvas( 700,700 )
WaitForRedraw() ; alert ( "resize canvas 400 x 400" )
//=================================================================
docRef = null;
backColor = null;
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES)
alert ("Document in now Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
======================Layers_Templates==================================
#target photoshop
app.bringToFront(); // Layers_Templates
if (app.documents.length == 0) { var docRef = app.documents.add(); }
else { var docRef = app.activeDocument; }
WaitForRedraw(); alert ("Start_with_a_document" )
//==================================================================
if (docRef.layers.length < 2) { docRef.artLayers.add(); }
var activeLayerName = docRef.activeLayer.name;
WaitForRedraw(); alert ("Add A Layer called " + activeLayerName )
//==================================================================
var newname = "First_added" ;
docRef.activeLayer.name = newname ;
WaitForRedraw(); alert ("Renamed Layer to " + newname)
//==================================================================
var layerRef = docRef.artLayers.add();
activeLayerName = docRef.activeLayer.name;
WaitForRedraw(); alert ("Added Another Layer = "+layerRef.name+"\r Name = "+activeLayerName+"\r Type = "+layerRef.kind)
//==================================================================
var layerRef2 = docRef.artLayers[1].duplicate();
WaitForRedraw(); alert ("Duplicate Layer[1] = "+layerRef2.name+"\r bounds = "+layerRef2.bounds )
//==================================================================
var layerRef3 = docRef.layers["Background"].duplicate();
WaitForRedraw(); alert ("Duplicate Background Layer = " + layerRef3.name )
//==================================================================
var layerslist ="layerslist= \r"
for (var i= 0; i < docRef.layers.length ; i++)
{ layerslist = layerslist+ docRef.layers[i].name +" \r";
} WaitForRedraw(); alert ("Print out Layer[0,1,..] " + layerslist)
//==================================================================
layerRef3.remove();
WaitForRedraw(); alert ("Removed LayerRef3 " )
//==================================================================
var layerRef3 = app.activeDocument.artLayers.add()
layerRef3.name = "MyBlendLayer"
WaitForRedraw(); alert ("Add and Name a layer = "+layerRef3.name)
//==================================================================
layerRef3.blendMode = BlendMode.NORMAL
WaitForRedraw(); alert ("View Blend and Opacity"+"\rmode = "+layerRef3.blendMode+"\rop = "+layerRef3.opacity )
//==================================================================
var testval = docRef.activeLayer.isBackgroundLayer
WaitForRedraw(); alert ("isBackgroundLayer? " + testval)
//==================================================================
docRef.activeLayer = docRef.layers["Background"] // define new active layer name
testval = docRef.activeLayer.isBackgroundLayer
WaitForRedraw(); alert ("isBackgroundLayer? " + testval)
//=================================================================
layerRef3.visible = false;
WaitForRedraw(); alert ("Turn layerRef3 off " )
//=================================================================
app.activeDocument.layers[ 1].move(app.activeDocument.layers[3], ElementPlacement.PLACEAFTER);
WaitForRedraw(); alert ("move layer[1] to after layer[3] " ) ;
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES)
alert ("Document in now Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
========================Text_Templates===============================
#target photoshop
app.bringToFront(); // Text_Tutorial
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;
app.displayDialogs = DialogModes.NO;
var docRef = app.documents.add(8, 5, 72);
WaitForRedraw() ; alert ( "add a 8 x 5 document at 72 dpi") ;
//=================================================================
var textColor = new SolidColor;
textColor.rgb.red = 255;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;
var newTextLayer = docRef.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.contents = "Hello, World!";
newTextLayer.textItem.position = Array(0.75, 2.75);
newTextLayer.textItem.size = 48;
WaitForRedraw() ; alert ( "Position at 0.75 and 2.75 with size at 48") ;
//=================================================================
newTextLayer.textItem.color = textColor;
WaitForRedraw() ; alert ( "set color to \r"+ textColor.rgb.red +textColor.rgb.green +textColor.rgb.blue) ;
//=================================================================
newTextLayer.justification = Justification.LEFTJUSTIFIED ;
WaitForRedraw() ; alert ( "LEFTJUSTIFIED \r") ;
//=================================================================
var fontlist =""
for (var i= 0; i < app.fonts.length ; i++)
{ fontlist = fontlist +i+" "+ app.fonts[i].name +" \r";
}
WaitForRedraw() ; alert ( "fontlist = \r" + fontlist ) ;
//=================================================================
newTextLayer.textItem.font = "Braggadocio";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Playbill";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Zapfino";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "MyriadStd-Sketch";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Onyx";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "RosewoodStd-Regular";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Impact";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Stencil";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
newTextLayer.textItem.font = "Times-Bold";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES)
alert ("Document in now Closed" )
//=================================================================
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=========================FILTERS_Template========================
#target photoshop // FILTERS_Tutorials
var startRulerUnits = app.preferences.rulerUnits // default preferences
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS //change settings
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = app.path.toString() + "/Samples/Lake(16bit).tif";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Opened file = \r" + fileName ) ;
//=================================================================
docRef.bitsPerChannel = BitsPerChannelType.EIGHT
docRef.changeMode( ChangeMode.RGB);
WaitForRedraw() ; alert ( "Set 8Bit per Channel = \r") ;
//=================================================================
var layerRef1 = docRef.layers["Background"].duplicate();
WaitForRedraw() ; alert ( "duplicated backgound" ) ;
//=================================================================
layerRef1.name = "layerRef1"
layerRef1.blendMode = BlendMode.NORMAL
WaitForRedraw() ; alert ( "renamed to layerRef1 with blend mode \r" + layerRef1.blendMode) ;
//=================================================================
docRef.activeLayer = docRef.layers["layerRef1"]
WaitForRedraw() ; alert ( "now layerRef1 is active \r") ;
//=================================================================
var selBounds1 = Array( Array(50, 150),
Array(300, 150),
Array(300, 400),
Array(50, 400) );
docRef.selection.select( selBounds1);
WaitForRedraw() ; alert ( "apply selection \r" + selBounds1 ) ;
//=================================================================
layerRef1.desaturate();
WaitForRedraw() ; alert ( "desaturate()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.invert();
WaitForRedraw() ; alert ( "invert()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.equalize();
WaitForRedraw() ; alert ( "equalize()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyAverage();
WaitForRedraw() ; alert ( "applyAverage()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyBlur();
WaitForRedraw() ; alert ( "applyBlur()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyBlurMore();
WaitForRedraw() ; alert ( "applyBlurMore()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyDifferenceClouds();
WaitForRedraw() ; alert ( "applyDifferenceClouds()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.autoLevels();
WaitForRedraw() ; alert ( "autoLevels()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.autoContrast();
WaitForRedraw() ; alert ( "autoContrast()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyDespeckle();
WaitForRedraw() ; alert ( "applyDespeckle()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applySharpen();
WaitForRedraw() ; alert ( "applySharpen()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applySharpenEdges();
WaitForRedraw() ; alert ( "applySharpenEdges()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applySharpenMore();
WaitForRedraw() ; alert ( "applySharpenMore()" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyUnSharpMask( 50,4,0);
WaitForRedraw() ; alert ( "applyUnSharpMask(50,4,0)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.posterize(4);
WaitForRedraw() ; alert ( "posterize(4)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.threshold(70);
WaitForRedraw() ; alert ( "threshold(70)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyAddNoise( 12,NoiseDistribution.GAUSSIAN, false);
WaitForRedraw() ; alert ( "applyAddNoise(12,NoiseDistribution.GAUSSIAN, false)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyGaussianBlur(5);
WaitForRedraw() ; alert ( "applyGaussianBlur(5)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.adjustBrightnessContrast(33,33);
WaitForRedraw() ; alert ( "adjustBrightnessContrast(33,33)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyDustAndScratches( 2,0);
WaitForRedraw() ; alert ( "applyDustAndScratches(2,0)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyHighPass(4);
WaitForRedraw() ; alert ( "applyHighPass(4)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyMedianNoise(1);
WaitForRedraw() ; alert ( "applyMedianNoise(1)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyPinch(50);
WaitForRedraw() ; alert ( "applyPinch(50)" ) ; // 61
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyRipple( 100, RippleSize.LARGE); //MEDIUM SMALL
WaitForRedraw() ; alert ( "applyRipple(100, RippleSize.LARGE)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyTwirl(50);
WaitForRedraw() ; alert ( "applyTwirl(50)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyZigZag( 10,5, ZigZagType.AROUNDCENTER );
WaitForRedraw() ; alert ( "applyZigZag(10,5,ZigZagType.AROUNDCENTER )" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyMotionBlur(0,10);
WaitForRedraw() ; alert ( "applyMotionBlur(0,10)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyRadialBlur( 10, RadialBlurMethod.SPIN, RadialBlurQuality.BEST );
WaitForRedraw() ; alert ( "applyRadBlur(10, Method.SPIN, Quality.BEST ); " ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyMaximum( 5 );
WaitForRedraw() ; alert ( "applyMaximum( 5 )" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyMinimum(5);
WaitForRedraw() ; alert ( "applyMinimum(5)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyOceanRipple(7,10);
WaitForRedraw() ; alert ( "applyOceanRipple(7,10)" ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyOffset( 5,5, OffsetUndefinedAreas.SETTOBACKGROUND );
WaitForRedraw() ; alert ( "applyOffset(5,5,UndefinedAreas.REPEATEDGEPIXELS ) " ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
layerRef1.applyDiffuseGlow( 6, 10,15 ); //
WaitForRedraw() ; alert ( "applyDiffuseGlow(6, 10,15 ) " ) ;
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
docRef = null;
backColor = null;
app.preferences.rulerunits = startRulerUnits
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES)
alert ("Document in now Closed" )
//=================================================================
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function stepback()
{ var desc55 = new ActionDescriptor();
var ref14 = new ActionReference();
ref14.putEnumerated( stringIDToTypeID("historyState"),stringIDToTypeID("ordinal"),stringIDToTypeID("previous") );
desc55.putReference( stringIDToTypeID("null"), ref14 );
executeAction( stringIDToTypeID("select"),desc55, DialogModes.NO );
}
==========================CUT/PASTE_Templates======================
#target photoshop // CUT/PASTE_Tutorials
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = app.path.toString() + "/Samples/Lake(16bit).tif";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Opened file = \r" + fileName ) ;
//=================================================================
docRef.bitsPerChannel = BitsPerChannelType.EIGHT
docRef.changeMode( ChangeMode.RGB);
WaitForRedraw() ; alert ( "Set to eight bits RGB" ) ;
//=================================================================
var selBounds1 = Array( Array(50, 150),
Array(300, 150),
Array(300, 400),
Array(50, 400) );
docRef.selection.select( selBounds1);
WaitForRedraw() ; alert ( "apply selection \r" + selBounds1 ) ;
//=================================================================
docRef.selection.copy( );
WaitForRedraw() ; alert ( "copy selection" ) ;
//=================================================================
docRef.paste(); // creates layer 1 with clip
WaitForRedraw() ; alert ( "paste selection" ) ;
//=================================================================
docRef.activeLayer.name = "Clip"
var Clip = docRef.activeLayer
WaitForRedraw() ; alert ( "activeLayer name set to clip " ) ;
//=================================================================
Clip.translate(50,50);
WaitForRedraw() ; alert ( "translate Clip (50,50)" ) ;
//=================================================================
Clip.rotate( 30 ,AnchorPosition.MIDDLECENTER);
WaitForRedraw() ; alert ( "rotate Clip 30 from middle" ) ;
//=================================================================
Clip.resize( 30 ,50,AnchorPosition.MIDDLECENTER);
WaitForRedraw() ; alert ( "resize Clip 30 ,50, from middle" ) ;
//=================================================================
Clip.merge();
WaitForRedraw() ; alert ( "merge Clip down" ) ;
//=================================================================
var selBounds2 = Array( Array(30, 50),
Array(100, 50),
Array(100, 100),
Array(30, 100) );
docRef.selection.select( selBounds2);
WaitForRedraw() ; alert ( "apply selection \r" + selBounds2 ) ;
//=================================================================
docRef.selection.cut( );
WaitForRedraw() ; alert ( "cut selection" ) ;
//=================================================================
docRef = null;
backColor = null;
app.preferences.rulerunits = startRulerUnits
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) ; alert ("Document in now Closed" )
//=================================================================
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
==========================Masking_Templates=========================
#target photoshop // Masking_Tutorials
var startRulerUnits = app.preferences.rulerUnits // default preferences
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS //change settings
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) { app.activeDocument.close() } // first close all the open documents
WaitForRedraw() ; alert ( "close all open documents" ) ;
//=================================================================
var fileName = app.path.toString() + "/Samples/Lake(16bit).tif";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Opened file = \r" + fileName ) ;
//=================================================================
docRef.bitsPerChannel = BitsPerChannelType.EIGHT
docRef.changeMode( ChangeMode.RGB);
WaitForRedraw() ; alert ( "Set 8Bit per Channel = \r") ;
//=================================================================
var layerRef1 = docRef.layers["Background"].duplicate();
WaitForRedraw() ; alert ( "duplicated backgound" ) ;
//=================================================================
layerRef1.name = "layerRef1"
layerRef1.blendMode = BlendMode.NORMAL
WaitForRedraw() ; alert ( "renamed to layerRef1 with blend mode \r" + layerRef1.blendMode) ;
//=================================================================
docRef.activeLayer = docRef.layers["layerRef1"] // define new active layer name
WaitForRedraw() ; alert ( "layerRef1 is active") ;
//=================================================================
docRef.activeLayer.desaturate()
WaitForRedraw() ; alert ( "desaturate") ;
//=================================================================
CreateMask()
WaitForRedraw() ; alert ( "CreateMask") ;
//=================================================================
selectmask()
WaitForRedraw() ; alert ( "selectmask") ;
//=================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 0
colorRef.rgb.green = 0
colorRef.rgb.blue = 0
var selBounds1 = Array( Array(50, 50),
Array(300, 50),
Array(300, 300),
Array(50, 300) );
docRef.selection.select( selBounds1);
WaitForRedraw(); alert ( "selBounds1 \r"+ selBounds1 )
//=================================================================
app.activeDocument.selection.fill(colorRef) ;
WaitForRedraw() ; alert ( "fill select \r"+colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
//=================================================================
applymask()
WaitForRedraw() ; alert ( "applymask") ;
//=================================================================
docRef.selection.deselect();
WaitForRedraw() ; alert ( "deselect") ;
//=================================================================
docRef.layers["Background"].visible = false;
WaitForRedraw() ; alert ( "Background is invisible ") ;
//=================================================================
docRef = null;
backColor = null;
app.preferences.rulerunits = startRulerUnits
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
//=================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) ; alert ("Document in now Closed" )
//=================================================================
function CreateMask()
{ var descUsng = new ActionDescriptor();
var ref92_Msk = new ActionReference();
descUsng.putClass( stringIDToTypeID("new") , stringIDToTypeID("channel"));
ref92_Msk.putEnumerated( stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask") );
descUsng.putReference( stringIDToTypeID("at") , ref92_Msk );
descUsng.putEnumerated( stringIDToTypeID("using") , stringIDToTypeID("userMaskEnable"), stringIDToTypeID("revealAll") );
executeAction( stringIDToTypeID("make") , descUsng, DialogModes.NO );
}
function selectmask()
{ var desc_MkVs = new ActionDescriptor();
var ref_Trgt = new ActionReference();
ref_Trgt.putEnumerated( stringIDToTypeID("channel") , stringIDToTypeID("ordinal") , stringIDToTypeID("targetEnum") );
desc_MkVs.putReference( stringIDToTypeID("null") , ref_Trgt );
desc_MkVs.putBoolean( stringIDToTypeID("makeVisible"), false );
executeAction( stringIDToTypeID("select") , desc_MkVs, DialogModes.NO );
}
function applymask()
{ var desc_Aply = new ActionDescriptor();
var ref_Trgt = new ActionReference();
ref_Trgt.putEnumerated( stringIDToTypeID("channel") , stringIDToTypeID("ordinal"),stringIDToTypeID("targetEnum") );
desc_Aply.putReference( stringIDToTypeID("null") , ref_Trgt );
desc_Aply.putBoolean( stringIDToTypeID("apply") , true );
executeAction( stringIDToTypeID("delete") , desc_Aply, DialogModes.NO );
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
==========================Dialog_Templates===================================
#target photoshop // Dialog_Tutorials
var message = "Welcome to " + app.name;
message += " version " + app.version + "\r\r";
message += "Iβm installed in " + app.path.fsName + "\r\r"
message += "You have this much memory available for Adobe Photoshop CS2: " + app.freeMemory + "\r\r"
var documentsOpen = app.documents.length
message += "You currently have " + documentsOpen + " document(s) open.\r\r"
WaitForRedraw(); alert( message) // display the message to the user
var answer = confirm("Do you want me to set the foreground and background to my favorite colors?")
WaitForRedraw(); alert( "your answer was " + answer) ; // display the message to the user
if (answer) // answer will be true for a "Yes" answer and false for a "No" answer
{ app.foregroundColor.rgb.red = Math.random() * 255;
app.foregroundColor.rgb.green = Math.random() * 255;
app.foregroundColor.rgb.blue = Math.random() * 255;
app.backgroundColor.rgb.red = Math.random() * 255;
app.backgroundColor.rgb.green = Math.random() * 255;
app.backgroundColor.rgb.blue = Math.random() * 255;
}
if (documentsOpen == 0)
{ var sampleDocToOpen = File(app.path + "/Samples/Flower.psd")
message = "Would you like me to open a sample for you? ("
message += sampleDocToOpen.fsName
message += ")"
answer = confirm(message) // ask the user another question
if (answer) { open( sampleDocToOpen ) } // open the document accordingly
}
WaitForRedraw() ; alert( "loaded a picture "+ sampleDocToOpen.fsName)
var val = Number ( prompt ( ' Enter a nummer ' , 960 ) );
WaitForRedraw() ; alert( "The number you entered is "+ val)
var closeit = true; //######################
if ( closeit )
{ app.activeDocument.close( SaveOptions.DONOTSAVECHANGES)
alert ( "Document Closed" )
}
function WaitForRedraw()
{ var eventWait = charIDToTypeID("Wait"); // Wait
var enumRedrawComplete = charIDToTypeID("RdCm"); // RedrawComplete
var typeState = charIDToTypeID("Stte"); // typeState
var keyState = charIDToTypeID("Stte"); // keyState
var desc = new ActionDescriptor();
desc.putEnumerated( keyState, typeState, enumRedrawComplete);
executeAction( eventWait, desc, DialogModes.NO);
}
==========================COLOR_TO_TRANSPARENT==========================
#target photoshop // COLOR_TO_TRANSPARENT
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = "/Users/don_sauer/Desktop/Tiger.jpg";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Open File \r ");
//==================================================================
SelectColorRange(62, 10 ,10 , 10 )
WaitForRedraw() ; alert ( "SelectColorRange(62, 10 ,10 , 10 ) \r ");
//==================================================================
docRef.selection.invert();
WaitForRedraw() ; alert ( "invert selection \r ");
//==================================================================
docRef.selection.copy( );
docRef.paste(); // creates layer 1 with clip
WaitForRedraw() ; alert ( "copy and paste the selection \r ");
//==================================================================
docRef.activeLayer = docRef.layers["Background"]
docRef.activeLayer.visible = false;
WaitForRedraw() ; alert ( "make background invisible \r ");
//==================================================================
function SelectColorRange( fuzz , Red, Green, Blue )
{ var colorRef = new SolidColor
colorRef.rgb.red = Red;
colorRef.rgb.green = Green;
colorRef.rgb.blue = Blue;
var desc28 = new ActionDescriptor();
desc28.putInteger( charIDToTypeID( "Fzns" ), fuzz ); // Fuzzz
var desc29 = new ActionDescriptor();
desc29.putDouble( charIDToTypeID( "Lmnc" ), colorRef.lab.l );
desc29.putDouble( charIDToTypeID( "A " ), colorRef.lab.a );
desc29.putDouble( charIDToTypeID( "B " ), colorRef.lab.b );
desc28.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "LbCl" ), desc29 );
var desc30 = new ActionDescriptor();
desc30.putDouble( charIDToTypeID( "Lmnc" ), colorRef.lab.l );
desc30.putDouble( charIDToTypeID( "A " ), colorRef.lab.a );
desc30.putDouble( charIDToTypeID( "B " ), colorRef.lab.b );
desc28.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "LbCl" ), desc30 );
desc28.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "B " ), desc30 );
executeAction( charIDToTypeID( "ClrR" ), desc28, DialogModes.NO );
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=======================REMOVE_BACKGROUND===========================
#target photoshop // Remove Background Colors
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = "/Users/don_sauer/Desktop/Flower.jpg";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Open File \r ");
//==================================================================
MagicWand( 10.000000, 10.000000, 42 ) ; // needs the zeros
WaitForRedraw() ; alert ( "MagicWand at 10.000000,10.000000 \r ");
//==================================================================
GrowSelect( 32 )
WaitForRedraw() ; alert ( "GrowSelect at 32 \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ( "stepback" ) ;
SimilarSelect( 32 );
WaitForRedraw() ; alert ( "SimilarSelect at 32 \r ");
//==================================================================
docRef.selection.invert();
WaitForRedraw() ; alert ( "invert selection \r ");
docRef.selection.copy( );
docRef.paste();
WaitForRedraw() ; alert ( "paste to new layer \r ");
docRef.activeLayer = docRef.layers["Background"]
docRef.activeLayer.visible = false;
WaitForRedraw() ; alert ( "make background invisible \r ");
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function MagicWand( XX,YY, Tolerance )
{ var desc116 = new ActionDescriptor();
var desc117 = new ActionDescriptor();
var ref42 = new ActionReference();
ref42.putProperty( stringIDToTypeID("channel") , stringIDToTypeID("selection") );
desc116.putReference( stringIDToTypeID("null") , ref42 );
desc117.putUnitDouble( stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), XX );
desc117.putUnitDouble( stringIDToTypeID("vertical") , stringIDToTypeID("pixelsUnit"), YY );
desc116.putObject( stringIDToTypeID("to") , stringIDToTypeID("paint"), desc117 );
desc116.putInteger( stringIDToTypeID("tolerance") , Tolerance );
desc116.putBoolean( stringIDToTypeID("antiAlias") , true );
executeAction( stringIDToTypeID("set") , desc116, DialogModes.NO );
}
function GrowSelect( Tolerance )
{ var desc118 = new ActionDescriptor();
var ref43 = new ActionReference();
ref43.putProperty( stringIDToTypeID("channel"), stringIDToTypeID("selection") );
desc118.putReference( stringIDToTypeID("null"), ref43 );
desc118.putInteger( stringIDToTypeID("tolerance"), Tolerance );
desc118.putBoolean( stringIDToTypeID("antiAlias"), true );
executeAction( stringIDToTypeID("grow"), desc118, DialogModes.NO );
}
function SimilarSelect( Tolerance )
{ var desc119 = new ActionDescriptor();
var ref44 = new ActionReference();
ref44.putProperty( stringIDToTypeID("channel"), stringIDToTypeID("selection") );
desc119.putReference( stringIDToTypeID("null"), ref44 );
desc119.putInteger( stringIDToTypeID("tolerance"), Tolerance );
desc119.putBoolean( stringIDToTypeID("antiAlias"), true );
executeAction( stringIDToTypeID("similar"), desc119, DialogModes.NO );
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function stepback()
{ var desc55 = new ActionDescriptor();
var ref14 = new ActionReference();
ref14.putEnumerated( stringIDToTypeID("historyState"),stringIDToTypeID("ordinal"),stringIDToTypeID("previous") );
desc55.putReference( stringIDToTypeID("null"), ref14 );
executeAction( stringIDToTypeID("select"),desc55, DialogModes.NO );
}
=======================IMAGE_TO_FILE_TO_GET_PIXEL_COLORS================
#target photoshop // Get Pixel Colors
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
WaitForRedraw() ; alert ( "preferences saved")
//==================================================================
var docRef = app.documents.add(520, 340, 72, "NewDocument", NewDocumentMode.RGB, DocumentFill.WHITE);
WaitForRedraw() ; alert ( "create White RBG document");
//==================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 0; colorRef.rgb.green= 255; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "foregroundColor set");
//==================================================================
colorRef.rgb.red = 255; colorRef.rgb.green= 255; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "backgroundColor set");
//==================================================================
var selBounds1 = Array( Array(50, 50),
Array(200, 50),
Array(200, 200),
Array(50, 200) );
docRef.selection.select( selBounds1);
WaitForRedraw(); alert ( "selBounds1 \r"+ selBounds1 )
//==================================================================
colorRef.rgb.red = 0; colorRef.rgb.green= 255; colorRef.rgb.blue= 255;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.activeDocument.selection.fill(colorRef) ;
WaitForRedraw() ; alert ( "fill select with new color" )
//==================================================================
foregroundColor.rgb = getPixel( 100, 100 );
WaitForRedraw() ; alert ("Color change \r"+foregroundColor.rgb.red+" "+foregroundColor.rgb.green+" "+foregroundColor.rgb.blue)
//==================================================================
app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
//==================================================================
function getPixel( varX, varY )
{ saveRaw();
WaitForRedraw() ; alert ( "Image is now in file a ");
//==================================================================
return readPixelRGB( varX, varY );
WaitForRedraw() ; alert ( "Read Whole file to find Pixel ");
//==================================================================
}
function saveRaw( varFile )
{ WaitForRedraw() ; alert ( "input variable = "+ varFile);
if (varFile == undefined ) { varFile = Folder.temp.fsName + 'Temp.raw'; }
WaitForRedraw() ; alert ( "creating varFile = "+ varFile);
//==================================================================
WaitForRedraw() ; alert ( "Will now step through executeAction code ");
//==================================================================
var desc1 = new ActionDescriptor();
desc1.putBoolean( strID( 'channelsInterleaved' ), true );
WaitForRedraw() ; alert ( "desc1.count = "+ desc1.count); // 1
var runid = desc1.getKey(0);
WaitForRedraw() ; alert ( "desc1.StringID = " + typeIDToStringID(runid) ); // 44
WaitForRedraw() ; alert ( "desc1.CharID = " + typeIDToCharID(runid) ); // Chnl
WaitForRedraw() ; alert ( "desc1.getBoolean = "+ desc1.getBoolean(runid) ); //true
var desc2 = new ActionDescriptor();
desc2.putObject( strID( 'as' ), strID( 'rawFormat' ), desc1 ); // key, classID, value
WaitForRedraw() ; alert ( "desc2.count = "+ desc2.count); //1
runid = desc2.getKey(0);
WaitForRedraw() ; alert ( "desc2.StringID = "+ typeIDToStringID(runid) ); // as
var classid = desc2.getClass(runid);
WaitForRedraw() ; alert ( "desc2.CharID = " + typeIDToStringID(classid) ); // rawFormat
varFile = Folder.temp.fsName + 'Temp.raw';
desc2.putPath( strID( 'in' ), new File( varFile ) ); // key , path
runid = desc2.getKey(1);
WaitForRedraw() ; alert ( "desc2.StringID(1) = "+ typeIDToStringID(runid) ); // in
var pathid = desc2.getPath(runid);
WaitForRedraw() ; alert ( "desc2.PathID(1) = "+ pathid ); // path
desc2.putBoolean( strID( 'copy' ), true );
runid = desc2.getKey(2);
WaitForRedraw() ; alert ( "desc2.StringID(2) = "+ typeIDToStringID(runid) ); // copy
WaitForRedraw() ; alert ( "desc2.CharID(2) = " + typeIDToCharID(runid) ); // Cpy
WaitForRedraw() ; alert ( "desc2.getBoolean(2) = "+ desc2.getBoolean(runid) ); // true
desc2.putBoolean( strID( 'lowerCase' ), true );
runid = desc2.getKey(3);
WaitForRedraw() ; alert ( "desc2.StringID(3) = " + typeIDToStringID(runid) ); // lowerCase
WaitForRedraw() ; alert ( "desc2.CharID(3) = " + typeIDToCharID(runid) ); // LwCs
WaitForRedraw() ; alert ( "desc2.getBoolean(3) = "+ desc2.getBoolean(runid) ); // true
WaitForRedraw() ; alert ( "desc2.count(3) = "+ desc2.count); // 4
executeAction( strID( 'save' ), desc2, DialogModes.NO );
WaitForRedraw() ; alert ( "saved File = "+ varFile);
}
function readPixelRGB( varX, varY, varFile )
{ if (varFile == undefined ) { varFile = Folder.temp.fsName + 'Temp.raw'; }
WaitForRedraw() ; alert ( "input varFile = "+ varFile);
var units, width, temp, rgbStr, rgbCol, i;
units = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
width = activeDocument.width;
preferences.rulerUnits = units;
temp = new File( varFile );
WaitForRedraw() ; alert ( "open varFile = "+ varFile);
temp.open( 'e' ); // e for edit
temp.encoding = 'BINARY';
rgbStr = temp.read(); // read whole binary file
temp.close();
i = 3 * ((varY * width) + varX); // pixel location 3bytes per pixel
rgbCol = new ( RGBColor );
rgbCol.red = rgbStr.charCodeAt( i );
rgbCol.green = rgbStr.charCodeAt( i + 1 );
rgbCol.blue = rgbStr.charCodeAt( i + 2 );
WaitForRedraw() ; alert ("rgbCol Color \r" + rgbCol.red+" "+ rgbCol.green+" "+ rgbCol.blue)
return rgbCol;
}
function strID( varID )
{ return stringIDToTypeID( varID ); //Converts string ID to runtime ID.//typeIDToStringID()
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=======================ApplyLayerStyle_Text==============================
#target photoshop
app.bringToFront(); // Text_Templates
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;
app.displayDialogs = DialogModes.NO;
var docRef = app.documents.add(8, 5, 72);
WaitForRedraw() ; alert ( "add a 8 x 5 document at 72 dpi") ;
//==================================================================
var textColor = new SolidColor;
textColor.rgb.red = 255;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;
var newTextLayer = docRef.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.contents = "Hello, World!";
newTextLayer.textItem.position = Array(0.75, 2.75);
newTextLayer.textItem.size = 48;
WaitForRedraw() ; alert ( "Position at 0.75 and 2.75 with size at 48") ;
//==================================================================
newTextLayer.textItem.color = textColor;
WaitForRedraw() ; alert ( "set color to \r"+ textColor.rgb.red +textColor.rgb.green +textColor.rgb.blue) ;
//==================================================================
newTextLayer.justification = Justification.LEFTJUSTIFIED ;
newTextLayer.textItem.font = "Braggadocio";
WaitForRedraw() ; alert ( "font " + newTextLayer.textItem.font ) ;
//==================================================================
docRef.artLayers[ 0].applyStyle("Sunset Sky (Text)");
WaitForRedraw() ; alert ("applyStyle Sunset Sky ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Overspray (Text)");
WaitForRedraw() ; alert ("applyStyle Overspray ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Chromed Satin (Text)");
WaitForRedraw() ; alert ("applyStyle Chromed Satin ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Chiseled Sky (Text)");
WaitForRedraw() ; alert ("applyStyle Chiseled Sky ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Basic Drop Shadow");
WaitForRedraw() ; alert ("applyStyle Basic Drop Shadow ");
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function stepback()
{ var desc55 = new ActionDescriptor();
var ref14 = new ActionReference();
ref14.putEnumerated( stringIDToTypeID("historyState"),stringIDToTypeID("ordinal"),stringIDToTypeID("previous") );
desc55.putReference( stringIDToTypeID("null"), ref14 );
executeAction( stringIDToTypeID("select"),desc55, DialogModes.NO );
}
=========================ApplyLayerStyle_Image===============================
#target photoshop // ApplyLayerStyle_Image
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = "/Users/don_sauer/Desktop/Tiger.jpg";
var docRef = open( File(fileName) );
WaitForRedraw() ; alert ( "Open File \r ");
//==================================================================
var docRef = app.activeDocument;
WaitForRedraw() ; alert ( "Is this background? \r "+ docRef.activeLayer.isBackgroundLayer);
//==================================================================
var layerRef3 = docRef.layers["Background"].duplicate();
layerRef3.name = "First_added" ;
docRef.activeLayer = docRef.layers["First_added"] // define new active layer name
docRef.activeLayer = layerRef3;
WaitForRedraw() ; alert ( "Is it still background? \r "+ docRef.activeLayer.isBackgroundLayer);
//==================================================================
var layerslist ="layerslist= \r"
for (var i= 0; i < docRef.layers.length ; i++)
{ layerslist = layerslist+ docRef.layers[i].name +" \r";
} WaitForRedraw(); alert ("Print out Layer[0,1,..] " + layerslist)
//==================================================================
docRef.artLayers[ 0].applyStyle("Puzzle (Image)");
WaitForRedraw() ; alert ("applyStyle Puzzle\r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Sepia Tone (Image)");
WaitForRedraw() ; alert ("applyStyle Sepia Tone\r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Sun Faded Photo (Image)");
WaitForRedraw() ; alert ("applyStyle Sun Faded Photo \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.artLayers[ 0].applyStyle("Negative (Image)");
WaitForRedraw() ; alert ("applyStyle Negative \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" )
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function stepback()
{ var desc55 = new ActionDescriptor();
var ref14 = new ActionReference();
ref14.putEnumerated( stringIDToTypeID("historyState"),stringIDToTypeID("ordinal"),stringIDToTypeID("previous") );
desc55.putReference( stringIDToTypeID("null"), ref14 );
executeAction( stringIDToTypeID("select"),desc55, DialogModes.NO );
}
========================ApplyLayerStyle_Texture==================================
#target photoshop // ApplyLayerStyle_Texture
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var docRef = app.documents.add(520, 340, 72, "NewDocument", NewDocumentMode.RGB, DocumentFill.WHITE);
WaitForRedraw() ; alert ( "create White RBG document");
//==================================================================
var selBounds1 = Array( Array(50, 50),
Array(200, 50),
Array(200, 200),
Array(50, 200) );
docRef.selection.select( selBounds1);
WaitForRedraw(); alert ( "selBounds1 \r"+ selBounds1 )
//==================================================================
docRef.selection.copy( );
docRef.paste();
WaitForRedraw() ; alert ( "copy and paste the selection \r ");
//==================================================================
docRef.activeLayer.applyStyle( "Blanket (Texture)");
WaitForRedraw() ; alert ("applyStyle Blanket \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.activeLayer.applyStyle( "Tie-Dyed Silk (Texture)");
WaitForRedraw() ; alert ("applyStyle Tie-Dyed \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.activeLayer.applyStyle("Nebula (Texture)");
WaitForRedraw() ; alert ("applyStyle Nebula \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
docRef.activeLayer.applyStyle("Sunspots (Texture)");
WaitForRedraw() ; alert ("applyStyle Sunspots \r ");
//==================================================================
stepback()
WaitForRedraw() ; alert ("stepback" ) ;
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function stepback()
{ var desc55 = new ActionDescriptor();
var ref14 = new ActionReference();
ref14.putEnumerated( stringIDToTypeID("historyState"),stringIDToTypeID("ordinal"),stringIDToTypeID("previous") );
desc55.putReference( stringIDToTypeID("null"), ref14 );
executeAction( stringIDToTypeID("select"),desc55, DialogModes.NO );
}
========================Image_Canvas_Resize==================================
#target photoshop // ApplyLayerStyle_Image
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
var fileName = "/Users/don_sauer/Desktop/Tiger.jpg";
var docRef = open( File(fileName) );
var w = docRef.height
var h = docRef.width
var r = docRef.resolution
WaitForRedraw() ; alert ( "Open File \r"+"w = "+w + "h = " +h + "r = " +r);
//==================================================================
docRef.resizeImage( 0.5*h, 0.5*w, r,ResampleMethod.BICUBIC); //resizeImage(h, w, res, Method)
WaitForRedraw() ; alert ( "Image resized to 50% \r");
//==================================================================
docRef.resizeCanvas( 1.7*w,1.7*h,AnchorPosition.MIDDLECENTER); //resizeCanvas(w, h, anchor)
WaitForRedraw() ; alert ( "Canvas resized by 70% \r");
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
=========================MosaicTiles==========================================
#target photoshop
app.bringToFront();
if (!app.documents.length > 0) // open sample file if no document is opened.
{ var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var docRef = app.documents.add(320, 240, 72, null, NewDocumentMode.RGB, DocumentFill.WHITE);
app.preferences.rulerUnits = strtRulerUnits;
}
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
mosaicTiles( 12, 3, 9 ); // inTileSize, inWidth, inLighten
function mosaicTiles( inTileSize, inWidth, inLighten )
{ var filterDescriptor = new ActionDescriptor();
filterDescriptor.putInteger( stringIDToTypeID("tileSize" ) , inTileSize );
filterDescriptor.putInteger( stringIDToTypeID("groutWidth" ) , inWidth );
filterDescriptor.putInteger( stringIDToTypeID("lightenGrout" ), inLighten );
executeAction( stringIDToTypeID("mosaicPlugin" ), filterDescriptor );
}
=============================PATHS_TEMPLATES========================
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) {app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) }
var docRef = app.documents.add(400, 400, 72, "Simple Line")
//WaitForRedraw() ; alert ( "New Document \r");
//==================================================================
var XYArray = new Array(2)
var colorRef = new SolidColor
var lineArray = new Array()
lineArray[0] = new PathPointInfo
lineArray[0].kind = PointKind.CORNERPOINT
XYArray = Array(100, 100);
ColorCircle( XYArray[0],XYArray[1] ,5 , "FF00FF");
lineArray[0].anchor = XYArray
lineArray[0].leftDirection = lineArray[0].anchor
lineArray[0].rightDirection = lineArray[0].anchor
lineArray[1] = new PathPointInfo
lineArray[1].kind = PointKind.CORNERPOINT
XYArray = Array(150, 200);
lineArray[1].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "FF00FF");
lineArray[1].leftDirection = lineArray[1].anchor
lineArray[1].rightDirection = lineArray[1].anchor
var lineSubPathArray = new Array()
lineSubPathArray[0] = new SubPathInfo()
lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[0].closed = false
lineSubPathArray[0].entireSubPath = lineArray
WaitForRedraw() ; alert ( "LEFT POINTS CURVE")
//==================================================================
var lineArray2 = new Array()
lineArray2[0] = new PathPointInfo
lineArray2[0].kind = PointKind.CORNERPOINT
XYArray = Array(170, 200)
lineArray2[0].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "0000FF");
lineArray2[0].leftDirection = lineArray2[0].anchor
lineArray2[0].rightDirection = lineArray2[0].anchor
lineArray2[1] = new PathPointInfo
lineArray2[1].kind = PointKind.CORNERPOINT
XYArray = Array(220, 100)
lineArray2[1].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "0000FF");
lineArray2[1].leftDirection = lineArray2[1].anchor
lineArray2[1].rightDirection = lineArray2[1].anchor
lineSubPathArray[1] = new SubPathInfo()
lineSubPathArray[1].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[1].closed = false
lineSubPathArray[1].entireSubPath = lineArray2
WaitForRedraw() ; alert ( "RIGHT POINTS CURVE")
//==================================================================
var lineArray3 = new Array()
lineArray3[0] = new PathPointInfo
lineArray3[0].kind = PointKind.CORNERPOINT
XYArray = Array(220, 80)
lineArray3[0].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "FFF00F");
WaitForRedraw() ; alert ( "A CORNERPOINT AT 220, 80")
//==================================================================
lineArray3[0].leftDirection = lineArray3[0].anchor
lineArray3[0].rightDirection = lineArray3[0].anchor
WaitForRedraw() ; alert ( "LEFT/RIGHT DIRECTION SET TO THIS ANCHOR")
//==================================================================
lineArray3[1] = new PathPointInfo
lineArray3[1].kind = PointKind.CORNERPOINT
XYArray = Array(160, 30)
lineArray3[1].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "000000");
WaitForRedraw() ; alert ( "A CORNERPOINT AT 160, 30")
//==================================================================
XYArray = Array(100, 30)
lineArray3[1].leftDirection = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "00FFFF");
WaitForRedraw() ; alert ( "LEFT DIR AT 100, 30")
//==================================================================
XYArray = Array(220, 30)
lineArray3[1].rightDirection = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "00FF00");
WaitForRedraw() ; alert ( "RIGHT DIR AT 220, 30")
//==================================================================
lineArray3[2] = new PathPointInfo
lineArray3[2].kind = PointKind.CORNERPOINT
XYArray = Array(100, 80)
lineArray3[2].anchor = XYArray
ColorCircle( XYArray[0],XYArray[1] ,5 , "FF00F0");
WaitForRedraw() ; alert ( "A CORNERPOINT AT 100, 80")
//==================================================================
lineArray3[2].leftDirection = lineArray3[2].anchor
lineArray3[2].rightDirection = lineArray3[2].anchor
lineSubPathArray[2] = new SubPathInfo()
lineSubPathArray[2].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[2].closed = false
lineSubPathArray[2].entireSubPath = lineArray3
WaitForRedraw() ; alert ( "LEFT/RIGHT DIRECTION SET TO THIS ANCHOR")
//==================================================================
var myPathItem = docRef.pathItems.add("A Line", lineSubPathArray); //create the path item
WaitForRedraw() ; alert ( "PATH ARRAY TO A PATH ITEM")
//==================================================================
colorRef.rgb.hexValue = "00FF00"; app.foregroundColor = colorRef;
WaitForRedraw() ; alert ( "SET COLOR TO 00FF00 ")
//==================================================================
PickBrush( "Hard Round 3 pixels" )
WaitForRedraw() ; alert ( "Set Up Brush ")
//==================================================================
myPathItem.strokePath( ToolType.BRUSH)
WaitForRedraw() ; alert ( "PATH Stroked IN")
//==================================================================
WaitForRedraw() ; alert ( "PATH name = " + myPathItem.name )
//==================================================================
var XYArray2 = new Array(2)
MyFile = new File( "/Users/don_sauer/Downloads/myfilepaths" )
MyFile.open ( "w", "?", "?");
for (i=0;i<app.activeDocument.pathItems.length;i++)
{ pathItem = app.activeDocument.pathItems[i];
MyFile.writeln( "[Path"+i+":"+pathItem.name+"]");
for (j=0;j<pathItem.subPathItems.length;j++)
{ subPathItem = pathItem.subPathItems[j];
MyFile.writeln( "[subPathItem "+j+":"+subPathItem.operation +"]");
for (k=0;k<subPathItem.pathPoints.length;k++)
{ PathPoint = subPathItem.pathPoints[k];
MyFile.writeln( "#" + k+ " "+ subPathItem.pathPoints[k].kind );
XYArray2 = subPathItem.pathPoints[k].anchor;
MyFile.writeln( "#" + k+ " Anchor = " +XYArray2 );
XYArray2 = subPathItem.pathPoints[k].leftDirection;
MyFile.writeln( "#" + k+ " leftDirection = " +XYArray2 );
XYArray2 = subPathItem.pathPoints[k].rightDirection;
MyFile.writeln( "#" + k+ " rightDirection = " +XYArray2 );
}
} MyFile.write( "\n");
} MyFile.close();
myPathItem.makeSelection()
WaitForRedraw() ; alert ( "Write Path to File")
//==================================================================
myPathItem.makeSelection()
WaitForRedraw() ; alert ( "make path a Selection")
//==================================================================
myPathItem.deselect()
WaitForRedraw() ; alert ( "deselect path " )
//==================================================================
docRef.flatten() ; //docRef.mergeVisibleLayersl()
WaitForRedraw() ; alert ( "Flatten all layers")
//==================================================================
app.preferences.rulerunits = startRulerUnits //restore beginning preferences
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
WaitForRedraw() ; alert ( "restore preferences \r")
//==================================================================
//app.activeDocument.close( SaveOptions.DONOTSAVECHANGES); alert ( "Document Closed" )
function PickBrush( BrushNameStr)
{ var desc5 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putClass( stringIDToTypeID("paintbrushTool") );
desc5.putReference( stringIDToTypeID("null"), ref3 );
executeAction( stringIDToTypeID("select"), desc5, DialogModes.NO );
var desc245 = new ActionDescriptor();
var ref65 = new ActionReference();
ref65.putName( stringIDToTypeID("brush" ) , BrushNameStr );
desc245.putReference( stringIDToTypeID("null" ) , ref65 );
executeAction( stringIDToTypeID("select") , desc245, DialogModes.NO );
}
function RasterLayer()
{ var desc33 = new ActionDescriptor();
var ref19 = new ActionReference();
ref19.putEnumerated( stringIDToTypeID("layer") , stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
desc33.putReference( stringIDToTypeID("null") , ref19 );
desc33.putEnumerated( stringIDToTypeID("what") , stringIDToTypeID( "rasterizeItem" ),stringIDToTypeID("shape"));
executeAction( stringIDToTypeID("rasterizeLayer"), desc33, DialogModes.NO );
}
function ColorCircle(x, y , r , ColHex)
{ var colorRef = new SolidColor
colorRef.rgb.hexValue = ColHex;
app.foregroundColor = colorRef
var top = y + r;
var bottom = y - r;
var left = x - r;
var right = x + r;
var desc12 = new ActionDescriptor();
var desc13 = new ActionDescriptor();
var desc14 = new ActionDescriptor();
var ref8 = new ActionReference();
ref8.putClass( stringIDToTypeID("contentLayer" ) );
desc12.putReference( stringIDToTypeID("null") , ref8 );
desc13.putClass( stringIDToTypeID("type") , stringIDToTypeID("solidColorLayer" ) );
desc14.putUnitDouble( stringIDToTypeID("top") , stringIDToTypeID("pixelsUnit") , top +0.000000 );
desc14.putUnitDouble( stringIDToTypeID("left") , stringIDToTypeID("pixelsUnit") , left +0.000000 );
desc14.putUnitDouble( stringIDToTypeID("bottom"), stringIDToTypeID("pixelsUnit") , bottom +0.000000 );
desc14.putUnitDouble( stringIDToTypeID("right") , stringIDToTypeID("pixelsUnit") , right +0.000000 );
desc13.putObject( stringIDToTypeID("shape") , stringIDToTypeID("ellipse") , desc14 );
desc12.putObject( stringIDToTypeID("using") , stringIDToTypeID("contentLayer" ), desc13 );
executeAction( stringIDToTypeID("make") , desc12, DialogModes.NO );
RasterLayer()
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
===============================Apply_Gradient=============================
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) {app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) }
var docRef = app.documents.add(400, 400, 72, "Apply Gradient")
//WaitForRedraw() ; alert ( "New Document \r");
//==================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 0; colorRef.rgb.green= 255; colorRef.rgb.blue= 255;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "foregroundColor set");
//==================================================================
colorRef.rgb.red = 255; colorRef.rgb.green= 255; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "backgroundColor set");
//=================================================================
var selBounds1 = Array( Array(50, 50),
Array(200, 50),
Array(200, 200),
Array(50, 200) );
docRef.selection.select( selBounds1);
WaitForRedraw(); alert ( "selBounds1 \r"+ selBounds1 )
//=================================================================
ApplyGradient( 41.000000,123.000000,220.000000, 123.000000, "Foreground to Background")
WaitForRedraw() ; alert ( "Apply Gradient set");
//=================================================================
function ApplyGradient( x1,y1,x2, y2, gradientname)
{ var desc5 = new ActionDescriptor();
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
var desc10 = new ActionDescriptor();
var desc11 = new ActionDescriptor();
var desc12 = new ActionDescriptor();
var list1 = new ActionList();
var list2 = new ActionList();
desc6.putUnitDouble( stringIDToTypeID("horizontal") , stringIDToTypeID("pixelsUnit") , x1 );
desc6.putUnitDouble( stringIDToTypeID("vertical") , stringIDToTypeID("pixelsUnit") , y1 );
desc5.putObject( stringIDToTypeID("from") , stringIDToTypeID("paint") , desc6 );
desc7.putUnitDouble( stringIDToTypeID("horizontal") , stringIDToTypeID("pixelsUnit") , x2 );
desc7.putUnitDouble( stringIDToTypeID("vertical") , stringIDToTypeID("pixelsUnit") , y2 );
desc5.putObject( stringIDToTypeID("to") , stringIDToTypeID("paint") , desc7 );
desc5.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 90.000000 );
desc5.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("gradientType") , stringIDToTypeID("linear"));
desc5.putBoolean( stringIDToTypeID("dither") , true );
desc5.putBoolean( stringIDToTypeID("useMask") , true );
desc8.putString( stringIDToTypeID("name") , gradientname);
desc8.putEnumerated( stringIDToTypeID("gradientForm"), stringIDToTypeID("gradientForm") , stringIDToTypeID("customStops") );
desc8.putDouble( stringIDToTypeID("interfaceIconFrameDimmed"), 4096.000000 );
desc9.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("colorStopType") , stringIDToTypeID("foregroundColor"));
desc9.putInteger( stringIDToTypeID("location") , 0 );
desc9.putInteger( stringIDToTypeID("midpoint") , 50 );
list1.putObject( stringIDToTypeID("colorStop") , desc9 );
desc10.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("colorStopType") , stringIDToTypeID("backgroundColor"));
desc10.putInteger( stringIDToTypeID("location") , 4096 );
desc10.putInteger( stringIDToTypeID("midpoint") , 50 );
list1.putObject( stringIDToTypeID("colorStop") , desc10 );
desc8.putList( stringIDToTypeID("colors") , list1 );
desc11.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 100.000000 );
desc11.putInteger( stringIDToTypeID("location") , 0 );
desc11.putInteger( stringIDToTypeID("midpoint") , 50 );
list2.putObject( stringIDToTypeID("transferSpec"), desc11 );
desc12.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 100.000000 );
desc12.putInteger( stringIDToTypeID("location") , 4096 );
desc12.putInteger( stringIDToTypeID("midpoint") , 50 );
list2.putObject( stringIDToTypeID("transferSpec"), desc12 );
desc8.putList( stringIDToTypeID("transparency"), list2 );
desc5.putObject( stringIDToTypeID("gradient") , stringIDToTypeID("gradientClassEvent"), desc8 );
executeAction( stringIDToTypeID("gradientClassEvent"), desc5, DialogModes.NO );
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
==================Wood======================================
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) {app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) }
var docRef = app.documents.add(400, 400, 72, "Wood")
WaitForRedraw() ; alert ( "New Document \r");
//==================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 250; colorRef.rgb.green= 157; colorRef.rgb.blue= 106;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "foregroundColor set");
//==================================================================
colorRef.rgb.red = 108; colorRef.rgb.green= 46; colorRef.rgb.blue= 22;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "backgroundColor set");
//==================================================================
ApplyGradient( 11.000000,13.000000,320.000000, 323.000000, "Foreground to Background")
WaitForRedraw() ; alert ( "Apply Gradient set");
//=================================================================
SprayedStrokes( 19, 24,"strokeDirRightDiag") ; // len, rad, strokeDirHorizontial,strokeDirVertical, trokeDirLeftDiag
WaitForRedraw() ; alert ( "Apply SprayedStrokes");
//=================================================================
PaintDaubs( 3, 2, "brushSimple") ; //size, sharp, brushLightRough,brushDarkRough,brushWideSharp,brushWideBlurry, ,brushSparkle
WaitForRedraw() ; alert ( "Apply PaintDaubs");
//=================================================================
alert ( "Stoke to get wood effect");
CallLiquify()
WaitForRedraw() ; alert ( "done");
//=================================================================
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
function CallLiquify()
{ var desc72 = new ActionDescriptor();
desc72.putString( stringIDToTypeID("using") , "Liquify..." );
executeAction( stringIDToTypeID("filter"), desc72, DialogModes.NO );
}
function PaintDaubs( size, sharp, Direction)
{ var desc71 = new ActionDescriptor();
desc71.putEnumerated( charIDToTypeID( "GEfk" ) , charIDToTypeID( "GEft" ), stringIDToTypeID("paintDaubs") );
desc71.putInteger( stringIDToTypeID("size") , size ) ;
desc71.putInteger( stringIDToTypeID("sharpen") , sharp );
desc71.putEnumerated( stringIDToTypeID("brushType") , stringIDToTypeID("brushType"),stringIDToTypeID(Direction) );
executeAction( stringIDToTypeID("paintDaubs") , desc71, DialogModes.NO );
}
function SprayedStrokes( Length, Radius, Direction)
{ var desc83 = new ActionDescriptor();
desc83.putEnumerated( charIDToTypeID( "GEfk" ) , charIDToTypeID( "GEft" ), stringIDToTypeID("separationSetup"));
desc83.putInteger( stringIDToTypeID("strokeLength") , Length );
desc83.putInteger( stringIDToTypeID("sprayRadius") , Radius ) ;
desc83.putEnumerated( stringIDToTypeID("strokeDirection") , stringIDToTypeID("strokeDirectionType"), stringIDToTypeID(Direction) );
executeAction( stringIDToTypeID("separationSetup") , desc83, DialogModes.NO );
}
function ApplyGradient( x1,y1,x2, y2, gradientname)
{ var desc5 = new ActionDescriptor();
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
var desc10 = new ActionDescriptor();
var desc11 = new ActionDescriptor();
var desc12 = new ActionDescriptor();
var list1 = new ActionList();
var list2 = new ActionList();
desc6.putUnitDouble( stringIDToTypeID("horizontal") , stringIDToTypeID("pixelsUnit") , x1 );
desc6.putUnitDouble( stringIDToTypeID("vertical") , stringIDToTypeID("pixelsUnit") , y1 );
desc5.putObject( stringIDToTypeID("from") , stringIDToTypeID("paint") , desc6 );
desc7.putUnitDouble( stringIDToTypeID("horizontal") , stringIDToTypeID("pixelsUnit") , x2 );
desc7.putUnitDouble( stringIDToTypeID("vertical") , stringIDToTypeID("pixelsUnit") , y2 );
desc5.putObject( stringIDToTypeID("to") , stringIDToTypeID("paint") , desc7 );
desc5.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 90.000000 );
desc5.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("gradientType") , stringIDToTypeID("linear"));
desc5.putBoolean( stringIDToTypeID("dither") , true );
desc5.putBoolean( stringIDToTypeID("useMask") , true );
desc8.putString( stringIDToTypeID("name") , gradientname);
desc8.putEnumerated( stringIDToTypeID("gradientForm"), stringIDToTypeID("gradientForm") , stringIDToTypeID("customStops") );
desc8.putDouble( stringIDToTypeID("interfaceIconFrameDimmed") , 4096.000000 );
desc9.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("colorStopType") , stringIDToTypeID("foregroundColor"));
desc9.putInteger( stringIDToTypeID("location") , 0 );
desc9.putInteger( stringIDToTypeID("midpoint") , 50 );
list1.putObject( stringIDToTypeID("colorStop") , desc9 );
desc10.putEnumerated( stringIDToTypeID("type") , stringIDToTypeID("colorStopType") , stringIDToTypeID("backgroundColor"));
desc10.putInteger( stringIDToTypeID("location") , 4096 );
desc10.putInteger( stringIDToTypeID("midpoint") , 50 );
list1.putObject( stringIDToTypeID("colorStop") , desc10 );
desc8.putList( stringIDToTypeID("colors") , list1 );
desc11.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 100.000000 );
desc11.putInteger( stringIDToTypeID("location") , 0 );
desc11.putInteger( stringIDToTypeID("midpoint") , 50 );
list2.putObject( stringIDToTypeID("transferSpec"), desc11 );
desc12.putUnitDouble( stringIDToTypeID("opacity") , stringIDToTypeID("percentUnit") , 100.000000 );
desc12.putInteger( stringIDToTypeID("location") , 4096 );
desc12.putInteger( stringIDToTypeID("midpoint") , 50 );
list2.putObject( stringIDToTypeID("transferSpec"), desc12 );
desc8.putList( stringIDToTypeID("transparency"), list2 );
desc5.putObject( stringIDToTypeID("gradient") , stringIDToTypeID("gradientClassEvent"), desc8 );
executeAction( stringIDToTypeID("gradientClassEvent"), desc5, DialogModes.NO );
}
==================MoltenLead======================================
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
while (app.documents.length) {app.activeDocument.close( SaveOptions.DONOTSAVECHANGES) }
var docRef = app.documents.add(400, 400, 72, "MoltenLead")
WaitForRedraw() ; alert ( "New Document \r");
//==================================================================
docRef.artLayers.add();
var activeLayerName = docRef.activeLayer.name;
WaitForRedraw(); alert ("Add A Layer called " + activeLayerName )
//==================================================================
var newname = "First_added" ;
docRef.activeLayer.name = newname ;
WaitForRedraw(); alert ("Renamed Layer to " + newname)
//==================================================================
var colorRef = new SolidColor
colorRef.rgb.red = 128; colorRef.rgb.green= 128; colorRef.rgb.blue= 128;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
docRef.selection.selectAll; //app.activeDocument.selection.selectAll ;
app.activeDocument.selection.fill( colorRef) ;
WaitForRedraw() ; alert ( "Set layer to gray \r");
//==================================================================
colorRef.rgb.red = 0; colorRef.rgb.green= 0; colorRef.rgb.blue= 0;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.foregroundColor = colorRef
WaitForRedraw() ; alert ( "foregroundColor set");
//==================================================================
colorRef.rgb.red = 255; colorRef.rgb.green= 255; colorRef.rgb.blue= 255;
WaitForRedraw() ; alert ( "Color change \r" +colorRef.rgb.red+" "+colorRef.rgb.green+" "+colorRef.rgb.blue)
app.backgroundColor = colorRef
WaitForRedraw() ; alert ( "backgroundColor set");
//==================================================================
executeAction( stringIDToTypeID("clouds"), undefined, DialogModes.NO );
WaitForRedraw() ; alert ( "Apply Clouds \r");
//==================================================================
executeAction( stringIDToTypeID("findEdges"), undefined, DialogModes.NO );
WaitForRedraw() ; alert ( "Find Edges \r");
//==================================================================
AdjustLevels( 216, 255,0.76); // min, max, gamma
WaitForRedraw() ; alert ( "Adjust levels \r");
//==================================================================
AdjustCurves( 0.000000,0.000000,183.000000,227.000000,255.000000,255.000000) ;
WaitForRedraw() ; alert ( "Adjust Curves \r");
//==================================================================
executeAction( stringIDToTypeID("invert"), undefined, DialogModes.NO );
WaitForRedraw() ; alert ( "Invert image \r");
//==================================================================
ApplyPlaster( 8,8,"lightPosLeft") ; // image balance,smooth, direction
WaitForRedraw() ; alert ( "Apply Plaster \r");
//==================================================================
UnSharpMask( 450.000000,1.000000 ,21) // amount,radius, threshold
WaitForRedraw() ; alert ( "applyUnSharpMask(450,1,21)" ) ;
//==================================================================
function AdjustLevels(min, max,gamma)
{ var desc21 = new ActionDescriptor();
var list3 = new ActionList();
var desc22 = new ActionDescriptor();
var ref10 = new ActionReference();
var list4 = new ActionList();
ref10.putEnumerated( stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("composite") );
desc22.putReference( stringIDToTypeID("channel"), ref10 );
list4.putInteger( min );
list4.putInteger( max );
desc22.putList( stringIDToTypeID("input") , list4 );
desc22.putDouble( stringIDToTypeID("gamma") , gamma );
list3.putObject( stringIDToTypeID("levelAdjustment"), desc22 );
desc21.putList( stringIDToTypeID("adjustment") , list3 );
executeAction( stringIDToTypeID("levels") , desc21, DialogModes.NO );
}
function AdjustCurves(x1,y1,x2,y2,x3,y3)
{ var desc23 = new ActionDescriptor();
var list5 = new ActionList();
var desc24 = new ActionDescriptor();
var ref11 = new ActionReference();
var list6 = new ActionList();
var desc25 = new ActionDescriptor();
var desc26 = new ActionDescriptor();
var desc27 = new ActionDescriptor();
ref11.putEnumerated( stringIDToTypeID("channel") , stringIDToTypeID("channel"), stringIDToTypeID("composite") );
desc24.putReference( stringIDToTypeID("channel") , ref11 );
desc25.putDouble( stringIDToTypeID("horizontal") , 0.000000 );
desc25.putDouble( stringIDToTypeID("vertical") , 0.000000 );
list6.putObject( stringIDToTypeID("paint") , desc25 );
desc26.putDouble( stringIDToTypeID("horizontal") , 183.000000 );
desc26.putDouble( stringIDToTypeID("vertical") , 227.000000 );
list6.putObject( stringIDToTypeID("paint") , desc26 );
desc27.putDouble( stringIDToTypeID("horizontal") , 255.000000 );
desc27.putDouble( stringIDToTypeID("vertical") , 255.000000 );
list6.putObject( stringIDToTypeID("paint") , desc27 );
desc24.putList( stringIDToTypeID("curve") , list6 );
list5.putObject( stringIDToTypeID("curveAdjustment") , desc24 );
desc23.putList( stringIDToTypeID("adjustment") , list5 );
executeAction( stringIDToTypeID("curves") , desc23, DialogModes.NO );
}
function ApplyPlaster(balance,smooth,lightPosition)
{ var desc28 = new ActionDescriptor();
desc28.putEnumerated( charIDToTypeID( "GEfk" ) , charIDToTypeID( "GEft" ), stringIDToTypeID("plaster") );
desc28.putInteger( stringIDToTypeID("imageBalance") , balance );
desc28.putInteger( stringIDToTypeID("smoothness") , smooth );
desc28.putEnumerated( stringIDToTypeID("lightPosition") , stringIDToTypeID("lightPosition"), stringIDToTypeID(lightPosition) );
executeAction( stringIDToTypeID("plaster") , desc28, DialogModes.NO );
}
function UnSharpMask(amount,radius,threshold)
{ var desc29 = new ActionDescriptor();
desc29.putUnitDouble( stringIDToTypeID("amount") , stringIDToTypeID("percentUnit"), amount );
desc29.putUnitDouble( stringIDToTypeID("radius") , stringIDToTypeID("pixelsUnit") , radius );
desc29.putInteger( stringIDToTypeID("threshold") , threshold );
executeAction( stringIDToTypeID("unsharpMask") , desc29, DialogModes.NO );
}
function WaitForRedraw() //" Wait" find/replace with "//Wait"
{ var desc = new ActionDescriptor();
desc.putEnumerated( stringIDToTypeID("state"), stringIDToTypeID("state"), stringIDToTypeID("redrawComplete" ));
executeAction( stringIDToTypeID("wait") , desc , DialogModes.NO);
}
==================View_Code_Names======================================
var codelist =" \r"
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDHz" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDLD" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDVt" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SprS" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "StrL" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SprR" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDir" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "StrD" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SprR" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDir" )) +" \r";
codelist = codelist +" "+typeIDToStringID(charIDToTypeID( "SDRD" )) +" \r";
alert ( codelist ); // 44
======================Create_Brush==================================
Draw Brush shape
Edit->Define_Brush_Preset..
Name brush and note itβs number
Select brush is Brush tip shape
Adjust size, angle, etc and save as new name
=================LAYER_STYLES=============================
Drop Shadow β Creates a shadow behind
Inner Shadow β Creates a shadow on top.
Outer Glow - Creates a glow behind
Inner Glow β Creates a glow on top of
Bevel and Emboss - Creates unique highlight and shadow effects
Satin - Gives a satin-like, glossy appearance.
Color Overlay - Fills with a solid color.
Gradient Overlay - Fills with a gradient.
Pattern Overlay - Fills with a pattern.
Stroke - Creates an outline using a solid color, gradient, or pattern.
=====================LAYER_STYLE_NONE=============================
// =======================================================
var desc146 = new ActionDescriptor();
var ref11 = new ActionReference();
var desc147 = new ActionDescriptor();
ref11.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Lefx" ) );
ref11.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc146.putReference( charIDToTypeID( "null" ), ref11 );
desc147.putUnitDouble( charIDToTypeID( "Scl " ), charIDToTypeID( "#Prc" ), 100.000000 );
desc146.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lefx" ), desc147 );
executeAction( charIDToTypeID( "setd" ), desc146, DialogModes.NO );
===================DROP_SHADOW=================================
// =======================================================
var desc164 = new ActionDescriptor();
var ref14 = new ActionReference();
var desc166 = new ActionDescriptor();
var desc165 = new ActionDescriptor();
desc167 = new ActionDescriptor();
var desc168 = new ActionDescriptor();
ref14.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Lefx" ) );
ref14.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc164.putReference( charIDToTypeID( "DrSh" ), ref14 );
desc165.putUnitDouble( charIDToTypeID( "Scl " ), charIDToTypeID( "#Prc" ), 100.000000 );
desc166.putBoolean( charIDToTypeID( "enab" ), true );
desc166.putEnumerated( charIDToTypeID( "Md " ), charIDToTypeID( "BlnM" ), charIDToTypeID( "CBrn" ) );
desc167.putDouble( charIDToTypeID( "Rd " ), 0.000000 );
desc167.putDouble( charIDToTypeID( "Grn " ), 0.000000 );
desc167.putDouble( charIDToTypeID( "Bl " ), 0.000000 );
desc166.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), desc167 );
desc166.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), 74.000000 );
desc166.putBoolean( charIDToTypeID( "uglg" ), true );
desc166.putUnitDouble( charIDToTypeID( "lagl" ), charIDToTypeID( "#Ang" ), 120.000000 );
desc166.putUnitDouble( charIDToTypeID( "Dstn" ), charIDToTypeID( "#Pxl" ), 15.000000 );
desc166.putUnitDouble( charIDToTypeID( "Ckmt" ), charIDToTypeID( "#Pxl" ), 21.000000 );
desc166.putUnitDouble( charIDToTypeID( "blur" ), charIDToTypeID( "#Pxl" ), 27.000000 );
desc166.putUnitDouble( charIDToTypeID( "Nose" ), charIDToTypeID( "#Prc" ), 10.000000 );
desc166.putBoolean( charIDToTypeID( "AntA" ), false );
desc168.putString( charIDToTypeID( "Nm " ), "Linear" );
desc166.putObject( charIDToTypeID( "TrnS" ), charIDToTypeID( "ShpC" ), desc168 );
desc165.putObject( charIDToTypeID( "null" ), charIDToTypeID( "DrSh" ), desc166 );
desc166.putBoolean( stringIDToTypeID( "layerConceals" ), true );
desc164.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lefx" ), desc165 );
executeAction( charIDToTypeID( "setd" ), desc164, DialogModes.NO );
==================INNER_SHADOW===================================
var desc176 = new ActionDescriptor();
var ref17 = new ActionReference();
var desc177 = new ActionDescriptor();
var desc178 = new ActionDescriptor();
var desc179 = new ActionDescriptor();
var desc180 = new ActionDescriptor();
ref17.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Lefx" ) );
ref17.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc176.putReference( charIDToTypeID( "null" ), ref17 );
desc177.putUnitDouble( charIDToTypeID( "Scl " ), charIDToTypeID( "#Prc" ), 100.000000 );
desc178.putBoolean( charIDToTypeID( "enab" ), true );
desc178.putEnumerated( charIDToTypeID( "Md " ), charIDToTypeID( "BlnM" ), stringIDToTypeID( "linearBurn" ) );
desc179.putDouble( charIDToTypeID( "Rd " ), 15.003891 );
desc179.putDouble( charIDToTypeID( "Grn " ), 70.000000 );
desc179.putDouble( charIDToTypeID( "Bl " ), 245.996109 );
desc178.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), desc179 );
desc178.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), 56.000000 );
desc178.putBoolean( charIDToTypeID( "uglg" ), true );
desc178.putUnitDouble( charIDToTypeID( "lagl" ), charIDToTypeID( "#Ang" ), 120.000000 );
desc178.putUnitDouble( charIDToTypeID( "Dstn" ), charIDToTypeID( "#Pxl" ), 11.000000 );
desc178.putUnitDouble( charIDToTypeID( "Ckmt" ), charIDToTypeID( "#Pxl" ), 4.000000 );
desc178.putUnitDouble( charIDToTypeID( "blur" ), charIDToTypeID( "#Pxl" ), 35.000000 );
desc178.putUnitDouble( charIDToTypeID( "Nose" ), charIDToTypeID( "#Prc" ), 31.000000 );
desc178.putBoolean( charIDToTypeID( "AntA" ), true );
desc180.putString( charIDToTypeID( "Nm " ), "Linear" );
desc178.putObject( charIDToTypeID( "TrnS" ), charIDToTypeID( "ShpC" ), desc180 );
desc177.putObject( charIDToTypeID( "IrSh" ), charIDToTypeID( "IrSh" ), desc178 );
desc176.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lefx" ), desc177 );
executeAction( charIDToTypeID( "setd" ), desc176, DialogModes.NO );
==================STOKE===================================
var desc185 = new ActionDescriptor();
var ref19 = new ActionReference();
var desc186 = new ActionDescriptor();
var desc187 = new ActionDescriptor();
var desc188 = new ActionDescriptor();
ref19.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Lefx" ) );
ref19.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc185.putReference( charIDToTypeID( "null" ), ref19 );
desc186.putUnitDouble( charIDToTypeID( "Scl " ), charIDToTypeID( "#Prc" ), 100.000000 );
desc187.putBoolean( charIDToTypeID( "enab" ), true );
desc187.putEnumerated( charIDToTypeID( "Styl" ), charIDToTypeID( "FStl" ), charIDToTypeID( "OutF" ) );
desc187.putEnumerated( charIDToTypeID( "PntT" ), charIDToTypeID( "FrFl" ), charIDToTypeID( "SClr" ) );
desc187.putEnumerated( charIDToTypeID( "Md " ), charIDToTypeID( "BlnM" ), stringIDToTypeID( "hardMix" ) );
desc187.putUnitDouble( charIDToTypeID( "Opct" ), charIDToTypeID( "#Prc" ), 57.000000 );
desc187.putUnitDouble( charIDToTypeID( "Sz " ), charIDToTypeID( "#Pxl" ), 35.000000 );
desc188.putDouble( charIDToTypeID( "Rd " ), 227.996109 );
desc188.putDouble( charIDToTypeID( "Grn " ), 255.000000 );
desc188.putDouble( charIDToTypeID( "Bl " ), 0.000000 );
desc187.putObject( charIDToTypeID( "Clr " ), charIDToTypeID( "RGBC" ), desc188 );
desc186.putObject( charIDToTypeID( "FrFX" ), charIDToTypeID( "FrFX" ), desc187 );
desc185.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lefx" ), desc186 );
executeAction( charIDToTypeID( "setd" ), desc185, DialogModes.NO );
=====================================================
2-5-13-15-39-40
dsauersanjose@aol.com
Don Sauer