Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arjunmurali1993/f5258692be7ce36456630aae09ce55d1 to your computer and use it in GitHub Desktop.
Save arjunmurali1993/f5258692be7ce36456630aae09ce55d1 to your computer and use it in GitHub Desktop.
This Photoshop Script saves two copies of the image - one with the Watermark and one without the watermark. To ensure that it works properly, the Watermark Layer must be on top of the Image Layer. Very useful for Photographers.
#target photoshop;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
var docName = thedoc.name;
if (docName.indexOf(".") != -1) {
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
} else {
var basename = docName;
}
//getting the location, if unsaved save to desktop
try {
var docPath = thedoc.path;
} catch (e) {
var docPath = "~/Desktop";
}
// JPEG Save As Options
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 12;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
//Save with Watermark
app.activeDocument.layers[0].visible = true;
app.activeDocument.layers[1].visible = true;
var filename = docPath + '/' + basename + "-with-watermark.jpg"
thedoc.saveAs((new File(filename)), jpegOptions, true);
//Save without Watermark
app.activeDocument.layers[0].visible = false;
app.activeDocument.layers[1].visible = true;
var filename = docPath + '/' + basename + "-without-watermark.jpg"
thedoc.saveAs((new File(filename)), jpegOptions, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment