#target photoshop // this command only works in Photoshop CS2 and higher // bring application forward for double-click events app.bringToFront(); if (!documents.length) {alert('There are no documents open.', 'No Document');} // ensure at least one document open else { main();} /////////////////////////////////////////////////////////////////////////////// // main - main function /////////////////////////////////////////////////////////////////////////////// function main() { /* textX and TextY positions text placement 0 and 0 Top Left corner of image in pixels */ var textX = 924000 ; var textY = 3407000; /* Internal Photoshop Text name */ //var fontName = "Arial"; var fontName = "TimesNewRomanPSMT"; //var fontName = "Tahoma"; //var fontName = "Arial"; /* Text Color */ textColor = new SolidColor; textColor.rgb.red = 134; textColor.rgb.green = 3; textColor.rgb.blue = 12; // remember users Ruler and Type Units and set ours var strtRulerUnits = app.preferences.rulerUnits; var strtTypeUnits = app.preferences.typeUnits; app.preferences.rulerUnits = Units.PIXELS; app.preferences.typeUnits = TypeUnits.PIXELS; var docName = app.activeDocument.name; var doc = app.activeDocument; text_layer = doc.artLayers.add(); // Add a Layer text_layer.name = "Time Stamp"; // Name Layer text_layer.kind = LayerKind.TEXT; // Make Layer a Text Layer text_layer.textItem.color = textColor; // set text layer color text_layer.textItem.font = fontName; // set text font text_layer.blendMode = BlendMode.NORMAL // blend mode text_layer.textItem.fauxBold = false; // Bold text_layer.textItem.fauxItalic = false; // Italic text_layer.textItem.underline = UnderlineType.UNDERLINEOFF; // Underlibn text_layer.textItem.capitalization = TextCase.NORMAL; // Case text_layer.textItem.antiAliasMethod = AntiAlias.SHARP; // antiAlias //if (doc.width >= doc.height) {var fontSize = 35;} //else {var fontSize = 35;} text_layer.textItem.size = 30; // set text font Size //text_layer.textItem.position = Array(fontSize, (doc.height - 2*fontSize )); // set text layers position in and down try{ text_layer.textItem.contents = timeStamp(); } catch (er) { alert("Error Setting Contents..."); } app.preferences.rulerUnits = strtRulerUnits; app.preferences.typeUnits = strtTypeUnits; } /////////////////////////////////////////////////////////////////////////////// // END - main function /////////////////////////////////////////////////////////////////////////////// function timeStamp(){ // Get the time and format it var digital = new Date(); var hours = digital.getHours(); var minutes = digital.getMinutes(); var seconds = digital.getSeconds(); var amOrPm = "AM"; if (hours > 11) amOrPm = "PM"; if (hours > 12) hours = hours - 12; if (hours == 0) hours = 12; if (minutes <= 9) minutes = "0" + minutes; if (seconds <= 9) seconds = "0" + seconds; // Get the date and format it var date = new Date(); var d = date.getDate(); var day = (d < 10) ? '0' + d : d; var m = date.getMonth() + 1; var month = (m < 10) ? '0' + m : m; var yy = date.getYear(); var year = (yy < 1000) ? yy + 1900 : yy; // create a variable with the fully formatted the time and date MonthNames = new Array("1","2","3","4","5","6","7","8","9","10", "11","12"); todaysDate = MonthNames[date.getMonth()] + "/" + date.getDate() + "/" + year; return todaysDate; }