Photoshop Script For Watermarks?


I’m not sure if this is an AppleScript thing or if it would be better in an actual language (Photoshop record actions is terrible), but I was wondering if there was a way in Photoshop to:

  • Take an image
  • Paste another image onto it
  • Start that image in the bottom right corner and move that image X pixels to the left and Y pixels up
  • Change the opacity to 40%
  • Save the image over the old one


Ordinarily Stack Overflow is about asking questions and getting answers. Moreso if you’ve made the effort to attempt the problem yourself; not about fulfilling requests. But since you pointed out that it would be beneficial to script your idea rather than run an action I’ve written about basics for you. Maybe you can pick it and run with it.

Firstly there are three languages that can script Photoshop. They are Apple-script, JavaScript and Visual Basic. Though VB is a tiny minority. JavaScript is the weapon of choice.

Here’s a JavaScript that will move your watermark and save over the existing file.
Not that pasting via scripting can be a bit tricky; in that it might not work unless you have cut or copied an image immediately beforehand. Pasting down twice doesn’t seem to work, so you’ll have to copy the image just before you run the script. You might alter the script to load in the file you need and place it in the other document:

// call the source document
var srcDoc = app.activeDocument;

//get the image with and height
var w = srcDoc.width.value;
var h = srcDoc.height.value;

// paste into current document

// set the name = "watermark"

// set the distance the watermark needs to move
var offsetX = 40;
var offsetY = 20;

//call the function to offset the image
moveActiveLayer(w, h, offsetX, offsetY)

//set opacity
srcDoc.activeLayer.opacity = 40

//flatten the image

//save the image

// function MOVE ACTIVE LAYER (layer name, deltaX, deltaY)
// ----------------------------------------------------------------
function moveActiveLayer(imageWidth, imageHeight, dX, dY)
    var x = parseFloat(srcDoc.activeLayer.bounds[0])
    var y = parseFloat(srcDoc.activeLayer.bounds[1])
    var x1 = parseFloat(srcDoc.activeLayer.bounds[2])
    var y1 = parseFloat(srcDoc.activeLayer.bounds[3])

    var moveX = (imageWidth - x1) - dX;
    var moveY = (imageHeight- y1) - dY;

    // coords from bottom right

    // Transform layer
    // =======================================================
    var id442 = charIDToTypeID( "Trnf" );
    var desc93 = new ActionDescriptor();
    var id443 = charIDToTypeID( "null" );
    var ref64 = new ActionReference();
    var id444 = charIDToTypeID( "Lyr " );
    var id445 = charIDToTypeID( "Ordn" );
    var id446 = charIDToTypeID( "Trgt" );
    ref64.putEnumerated( id444, id445, id446 );
    desc93.putReference( id443, ref64 );
    var id447 = charIDToTypeID( "FTcs" );
    var id448 = charIDToTypeID( "QCSt" );
    var id449 = charIDToTypeID( "Qcsa" );
    desc93.putEnumerated( id447, id448, id449 );
    var id450 = charIDToTypeID( "Ofst" );
    var desc94 = new ActionDescriptor();
    var id451 = charIDToTypeID( "Hrzn" );
    var id452 = charIDToTypeID( "#Pxl" );
    desc94.putUnitDouble( id451, id452, moveX );
    var id453 = charIDToTypeID( "Vrtc" );
    var id454 = charIDToTypeID( "#Pxl" );
    desc94.putUnitDouble( id453, id454, moveY );
    var id455 = charIDToTypeID( "Ofst" );
    desc93.putObject( id450, id455, desc94 );
    executeAction( id442, desc93, DialogModes.NO );

Answered By – Ghoul Fool

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published