//--------------------------------------------------- //---------- START OF USER CONFIG SECTION ----------- //--------------------------------------------------- // Where to place watermark vertically (in percentage) 0.0 -> 1.0 var pctVertical = 0.98; // Where to place watermark horizontally (in percentage) 0.0 -> 1.0 // The watermark text will be centered horizontally at this point. var pctHorizontal = 0.98; // Text Size: This value defines the font size of the watermark // text in percentage of image height. var textSize = 0.05; // Text Font: This string is the name of the font to use for the // watermark text. // var textFont = "CopperplateGothic-Bold" var textFont = "Vivaldii"; // Watermark Text: This is the actual watermark text string. var watermarkText = "John Q Public"; // Watermark Type: Define the watermark type to be applied. // Types are: Proof, Signature var watermarkType = "Signature"; //--------------------------------------------------- //---------- DOCUMENT PREPERATION SECTION ----------- //--------------------------------------------------- // Get a refernce to the current active document. var docRef = app.activeDocument; // Suppress all Photoshop dialogs app.displayDialogs = DialogModes.NO; var originalResolution = activeDocument.resolution; var resampleMethod = ResampleMethod.NONE; activeDocument.resizeImage(null,null,72,resampleMethod ); var strtRulerUnits = app.preferences.rulerUnits; var strtTypeUnits = app.preferences.typeUnits; app.preferences.rulerUnits = Units.PIXELS; app.preferences.typeUnits = TypeUnits.PIXELS; //--------------------------------------------------- //---------- FUNCTION DEFINITION SECTION ------------ //--------------------------------------------------- function applyProofWatermark() { // Screen Opacity: This value sets the layer opacity for the // watermarking layer. var screenOpacity = 30; var posVertical = docRef.height * pctVertical; var posHorizontal = docRef.width * pctHorizontal; var newTextLayer = docRef.artLayers.add(); newTextLayer.kind = LayerKind.TEXT; newTextLayer.textItem.justification = Justification.CENTER; newTextLayer.textItem.contents = watermarkText; newTextLayer.textItem.font = textFont; newTextLayer.textItem.position = Array(posHorizontal, posVertical); newTextLayer.textItem.size = (docRef.height * textSize); newTextLayer.textItem.createPath(); newTextLayer.remove(); docRef.pathItems.getByName("Work Path").makeSelection(); docRef.pathItems.getByName("Work Path").remove(); docRef.selection.copy(); docRef.paste(); docRef.activeLayer.name = "WaterMark"; docRef.activeLayer.opacity = screenOpacity; docRef.activeLayer.blendMode = BlendMode.SCREEN; // This code applies the "Bevel and Emboss" layer style // to the active layer. This code was generated using the // ScriptListener plugin. var id11 = charIDToTypeID( "setd" ); var desc4 = new ActionDescriptor(); var id12 = charIDToTypeID( "null" ); var ref1 = new ActionReference(); var id13 = charIDToTypeID( "Prpr" ); var id14 = charIDToTypeID( "Lefx" ); ref1.putProperty( id13, id14 ); var id15 = charIDToTypeID( "Lyr " ); var id16 = charIDToTypeID( "Ordn" ); var id17 = charIDToTypeID( "Trgt" ); ref1.putEnumerated( id15, id16, id17 ); desc4.putReference( id12, ref1 ); var id18 = charIDToTypeID( "T " ); var desc5 = new ActionDescriptor(); var id19 = charIDToTypeID( "Scl " ); var id20 = charIDToTypeID( "#Prc" ); desc5.putUnitDouble( id19, id20, 100.000000 ); var id21 = charIDToTypeID( "ebbl" ); var desc6 = new ActionDescriptor(); var id22 = charIDToTypeID( "enab" ); desc6.putBoolean( id22, true ); var id23 = charIDToTypeID( "hglM" ); var id24 = charIDToTypeID( "BlnM" ); var id25 = charIDToTypeID( "Scrn" ); desc6.putEnumerated( id23, id24, id25 ); var id26 = charIDToTypeID( "hglC" ); var desc7 = new ActionDescriptor(); var id27 = charIDToTypeID( "Rd " ); desc7.putDouble( id27, 255.000000 ); var id28 = charIDToTypeID( "Grn " ); desc7.putDouble( id28, 255.000000 ); var id29 = charIDToTypeID( "Bl " ); desc7.putDouble( id29, 255.000000 ); var id30 = charIDToTypeID( "RGBC" ); desc6.putObject( id26, id30, desc7 ); var id31 = charIDToTypeID( "hglO" ); var id32 = charIDToTypeID( "#Prc" ); desc6.putUnitDouble( id31, id32, 75.000000 ); var id33 = charIDToTypeID( "sdwM" ); var id34 = charIDToTypeID( "BlnM" ); var id35 = charIDToTypeID( "Mltp" ); desc6.putEnumerated( id33, id34, id35 ); var id36 = charIDToTypeID( "sdwC" ); var desc8 = new ActionDescriptor(); var id37 = charIDToTypeID( "Rd " ); desc8.putDouble( id37, 0.000000 ); var id38 = charIDToTypeID( "Grn " ); desc8.putDouble( id38, 0.000000 ); var id39 = charIDToTypeID( "Bl " ); desc8.putDouble( id39, 0.000000 ); var id40 = charIDToTypeID( "RGBC" ); desc6.putObject( id36, id40, desc8 ); var id41 = charIDToTypeID( "sdwO" ); var id42 = charIDToTypeID( "#Prc" ); desc6.putUnitDouble( id41, id42, 75.000000 ); var id43 = charIDToTypeID( "bvlT" ); var id44 = charIDToTypeID( "bvlT" ); var id45 = charIDToTypeID( "SfBL" ); desc6.putEnumerated( id43, id44, id45 ); var id46 = charIDToTypeID( "bvlS" ); var id47 = charIDToTypeID( "BESl" ); var id48 = charIDToTypeID( "InrB" ); desc6.putEnumerated( id46, id47, id48 ); var id49 = charIDToTypeID( "uglg" ); desc6.putBoolean( id49, true ); var id50 = charIDToTypeID( "lagl" ); var id51 = charIDToTypeID( "#Ang" ); desc6.putUnitDouble( id50, id51, 120.000000 ); var id52 = charIDToTypeID( "Lald" ); var id53 = charIDToTypeID( "#Ang" ); desc6.putUnitDouble( id52, id53, 30.000000 ); var id54 = charIDToTypeID( "srgR" ); var id55 = charIDToTypeID( "#Prc" ); desc6.putUnitDouble( id54, id55, 100.000000 ); var id56 = charIDToTypeID( "blur" ); var id57 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id56, id57, 5.000000 ); var id58 = charIDToTypeID( "bvlD" ); var id59 = charIDToTypeID( "BESs" ); var id60 = charIDToTypeID( "In " ); desc6.putEnumerated( id58, id59, id60 ); var id61 = charIDToTypeID( "TrnS" ); var desc9 = new ActionDescriptor(); var id62 = charIDToTypeID( "Nm " ); desc9.putString( id62, "Linear" ); var id63 = charIDToTypeID( "ShpC" ); desc6.putObject( id61, id63, desc9 ); var id64 = stringIDToTypeID( "antialiasGloss" ); desc6.putBoolean( id64, false ); var id65 = charIDToTypeID( "Sftn" ); var id66 = charIDToTypeID( "#Pxl" ); desc6.putUnitDouble( id65, id66, 0.000000 ); var id67 = stringIDToTypeID( "useShape" ); desc6.putBoolean( id67, false ); var id68 = stringIDToTypeID( "useTexture" ); desc6.putBoolean( id68, false ); var id69 = charIDToTypeID( "ebbl" ); desc5.putObject( id21, id69, desc6 ); var id70 = charIDToTypeID( "Lefx" ); desc4.putObject( id18, id70, desc5 ); executeAction( id11, desc4, DialogModes.NO ); } function applySignatureWatermark() { var posVertical = docRef.height * pctVertical; var posHorizontal = docRef.width * pctHorizontal; var textColor = new SolidColor; textColor.rgb.red = 255; textColor.rgb.green = 255; textColor.rgb.blue = 255; var newTextLayer = docRef.artLayers.add(); newTextLayer.kind = LayerKind.TEXT; newTextLayer.textItem.justification = Justification.RIGHT; newTextLayer.textItem.contents = watermarkText; newTextLayer.textItem.font = textFont; newTextLayer.textItem.position = Array(posHorizontal, posVertical); newTextLayer.textItem.size = (docRef.height * textSize); newTextLayer.textItem.color = textColor; // This code applies the outer glow layer style // to the active layer. This code was generated using the // ScriptListener plugin. var id499 = charIDToTypeID( "setd" ); var desc46 = new ActionDescriptor(); var id500 = charIDToTypeID( "null" ); var ref21 = new ActionReference(); var id501 = charIDToTypeID( "Prpr" ); var id502 = charIDToTypeID( "Lefx" ); ref21.putProperty( id501, id502 ); var id503 = charIDToTypeID( "Lyr " ); var id504 = charIDToTypeID( "Ordn" ); var id505 = charIDToTypeID( "Trgt" ); ref21.putEnumerated( id503, id504, id505 ); desc46.putReference( id500, ref21 ); var id506 = charIDToTypeID( "T " ); var desc47 = new ActionDescriptor(); var id507 = charIDToTypeID( "Scl " ); var id508 = charIDToTypeID( "#Prc" ); desc47.putUnitDouble( id507, id508, 100.000000 ); var id509 = charIDToTypeID( "OrGl" ); var desc48 = new ActionDescriptor(); var id510 = charIDToTypeID( "enab" ); desc48.putBoolean( id510, true ); var id511 = charIDToTypeID( "Md " ); var id512 = charIDToTypeID( "BlnM" ); var id513 = charIDToTypeID( "Mltp" ); desc48.putEnumerated( id511, id512, id513 ); var id514 = charIDToTypeID( "Clr " ); var desc49 = new ActionDescriptor(); var id515 = charIDToTypeID( "Rd " ); desc49.putDouble( id515, 0.000000 ); var id516 = charIDToTypeID( "Grn " ); desc49.putDouble( id516, 0.000000 ); var id517 = charIDToTypeID( "Bl " ); desc49.putDouble( id517, 0.000000 ); var id518 = charIDToTypeID( "RGBC" ); desc48.putObject( id514, id518, desc49 ); var id519 = charIDToTypeID( "Opct" ); var id520 = charIDToTypeID( "#Prc" ); desc48.putUnitDouble( id519, id520, 100.000000 ); var id521 = charIDToTypeID( "GlwT" ); var id522 = charIDToTypeID( "BETE" ); var id523 = charIDToTypeID( "SfBL" ); desc48.putEnumerated( id521, id522, id523 ); var id524 = charIDToTypeID( "Ckmt" ); var id525 = charIDToTypeID( "#Pxl" ); desc48.putUnitDouble( id524, id525, 8.000000 ); var id526 = charIDToTypeID( "blur" ); var id527 = charIDToTypeID( "#Pxl" ); desc48.putUnitDouble( id526, id527, 21.000000 ); var id528 = charIDToTypeID( "Nose" ); var id529 = charIDToTypeID( "#Prc" ); desc48.putUnitDouble( id528, id529, 0.000000 ); var id530 = charIDToTypeID( "ShdN" ); var id531 = charIDToTypeID( "#Prc" ); desc48.putUnitDouble( id530, id531, 0.000000 ); var id532 = charIDToTypeID( "AntA" ); desc48.putBoolean( id532, false ); var id533 = charIDToTypeID( "TrnS" ); var desc50 = new ActionDescriptor(); var id534 = charIDToTypeID( "Nm " ); desc50.putString( id534, "Default" ); var id535 = charIDToTypeID( "Crv " ); var list5 = new ActionList(); var desc51 = new ActionDescriptor(); var id536 = charIDToTypeID( "Hrzn" ); desc51.putDouble( id536, 0.000000 ); var id537 = charIDToTypeID( "Vrtc" ); desc51.putDouble( id537, 0.000000 ); var id538 = charIDToTypeID( "CrPt" ); list5.putObject( id538, desc51 ); var desc52 = new ActionDescriptor(); var id539 = charIDToTypeID( "Hrzn" ); desc52.putDouble( id539, 255.000000 ); var id540 = charIDToTypeID( "Vrtc" ); desc52.putDouble( id540, 255.000000 ); var id541 = charIDToTypeID( "CrPt" ); list5.putObject( id541, desc52 ); desc50.putList( id535, list5 ); var id542 = charIDToTypeID( "ShpC" ); desc48.putObject( id533, id542, desc50 ); var id543 = charIDToTypeID( "Inpr" ); var id544 = charIDToTypeID( "#Prc" ); desc48.putUnitDouble( id543, id544, 50.000000 ); var id545 = charIDToTypeID( "OrGl" ); desc47.putObject( id509, id545, desc48 ); var id546 = charIDToTypeID( "Lefx" ); desc46.putObject( id506, id546, desc47 ); executeAction( id499, desc46, DialogModes.NO ); } //---------------------------------------------- //---------- START OF MAIN SCRIPT -------------- //---------------------------------------------- switch (watermarkType) { case "Proof": applyProofWatermark(); break; case "Signature": applySignatureWatermark(); break; } // We're all done now. Just flatten the image. docRef.flatten(); // Restore all the settings that we changed at the beginning. If // we don't do this then the user might get confused. app.preferences.rulerUnits = strtRulerUnits; app.preferences.typeUnits = strtTypeUnits; activeDocument.resizeImage(null,null,originalResolution ,resampleMethod ); // Cleanup the references we've made. This is just good programming // practice. docRef = null; newTextLayer = null;