Add a drop shadow to Text Layer
I have tried searching around, but I cant figure out how to add a drop shadow to an existing text layer. My code is shown below...
I'm using Adobe Photoshop CS5
#target photoshop
var inputFolder = Folder.selectDialog("Select a folder of documents to process");
if(inputFolder) main();
function main(){
Count = 0;
//This is where the output folder is created in this case its called PageNumbered
var PathFolder = new Folder(decodeURI(inputFolder)+"/numbered");
if (PathFolder.exists == false) PathFolder.create();
var fileList = inputFolder.getFiles();
for (var i = 0; i < 5; i++) {
var file = fileList[0];
//////////////////////////////////////////////////////////////////////////////////////
//Change the line below to the extention of your input files ie:
//if the imput files are tif the line should be
// if (file instanceof File && file.name.match(/\.tif$/i)) {
if (file instanceof File && file.name.match(/\.png$/i)) {
open(file);
doc = app.activeDocument;
var startRulerUnits = preferences.rulerUnits
app.preferences.rulerUnits = Units.PIXELS
//Amend to suit.
var fontSize = 14;
var fontName = "Arial-BoldMT"; // NB: must be postscript name of font!
// This is the colour of the text in RGB
//Click foreground colour in Photoshop, choose your colour and read off the RGB values
//these can then be entered below.
var textColor = new SolidColor();
textColor.rgb.red = 255;
textColor.rgb.green =255;
textColor.rgb.blue = 255;
var newTextLayer = doc.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.size = fontSize;
newTextLayer.textItem.font = fontName;
newTextLayer.textItem.contents = ++Count;
newTextLayer.textItem.color = textColor;
newTextLayer.textItem.kind = TextType.PARAGRAPHTEXT;
newTextLayer.textItem.height = fontSize;
newTextLayer.textItem.width = doc.width;
//The line below is the text position (X Y) IE; 10 Pixels Right 10 Pixels Down
newTextLayer.textItem.position = Array(0, 12);
// Can be RIGHTJUSTFIED LEFTJUSTIFIED CENTERJUSTIFIED
newTextLayer.textItem.justification=Justification.CENTERJUSTIFIED;
doc.flatten();
var saveFile = new File(decodeURI(PathFolder) + "/" +activeDocument.name.slice(0,-4)+ "_" + (i+1) + ".png");
//SaveForWeb(saveFile,80);
//saveForWebPNG(saveFile);
savePNG_2(saveFile);
//SavePNG(saveFile);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
preferences.rulerUnits = startRulerUnits;
}
}
}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = jpegQuality; //0-100
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
}
function SavePNG(saveFile){
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.transparency = true;
activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
function saveForWebPNG(saveFile)
{
var opts, file;
opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.quality = 100;
opts.transparency = true;
file = new File(saveFile);
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
}
function savePNG_2(saveFile) {
docExportOptions = new ExportOptionsSaveForWeb
docExportOptions.format = SaveDocumentType.PNG; //-24 //JPEG, COMPUSERVEGIF, PNG-8, BMP
docExportOptions.transparency = true;
docExportOptions.blur = 0.0 ;
docExportOptions.includeProfile = false ;
docExportOptions.interlaced = false ;
docExportOptions.optimized = true ;
docExportOptions.quality = 100 ;
docExportOptions.PNG8 = false ;
activeDocument.exportDocument (saveFile,ExportType.SAVEFORWEB,docExportOptions) ;
}
