Watermarks - Generate from Filename or Prompt


#1

Friends:

I am new to Retrobatch. My workflow adds a graphic to one corner of a photo and a text watermark to another corner.

The text is the name of the dog that is in the picture.

I currently use Lightroom and a plugin called LR/Mogrify. I manually add the name of the dog to the Caption field and set the plugin to use the Caption for the text watermark and the export. This works but it is tedious and redundant! It is redundant because the name of the dog is always the first part of the filename. There is an underscore between the dog’s name and the ID number.

The best solution would be to use a string function on the filename and extract the dogs’s name.

The next best solution would be to run Retrobatch for each dog and be prompted for the text watermark.

Are either of these solutions possible?

Thanks,

Bert


#2

This is something you can do pretty easily with the new JavaScript node that was just released in Retrobatch 1.1.

Here’s the snippet of code you’ll need to put before your watermark node:

function processAsset(document, jsnode, asset) {
    
    var fileName = asset.outputFileName();
    var underscoreLocation = fileName.indexOf('_');
    if (underscoreLocation > 1) {
        var newName = fileName.slice(0, underscoreLocation);
        asset.setOutputFileName(newName)
    }
    else {
        console.log("Missing underscore in " + fileName)
    }
    
    return true;
}

And here’s a downloadable version of that Retrobatch workflow: name_underscore_watermark.retrobatch (2.6 KB)

Basically, the little script looks for the file name, detects if it has an underscore, and then sets the output filename to the letters that come before that. Then in the watermark node, we use the the file name token for the watermark, and it’s good to go.

The output for the file will be the name of the dog, without the underscore and numbers. If that’s a problem- let me know and I can make a slightly more complicated version that writes into metadata.


#3

Hi August:

Thanks! This is awesome.

If you don’t mind, I would like to keep the filename the same and have the dog name put in one of the metadata fields that Retrobatch can use.

I do this task every week to update a video slideshow that runs at my local animal shelter. This will save a lot of time.

Thanks again!

Bert


#4

OK, this is going to require a new build of Retrobatch to work, but I’ve got it going for you now. The new version allows you set set metadata values from JavaScript, which is what we’ll do with the updated version of the workflow.

So, first grab the updated version of Retrobatch from here: http://flyingmeat.com/download/latest/#retrobatch

And then here’s an updated version of the workflow: name_underscore_watermark.retrobatch (5.4 KB)

The JavaScript now looks like this:

function processAsset(document, jsnode, asset) {
    
    var fileName = asset.outputFileName();
    var underscoreLocation = fileName.indexOf('_');
    if (underscoreLocation > 1) {
        var newName = fileName.slice(0, underscoreLocation);
        
        // Set the title metadata, using ImageIO keys.
        asset.setMetaValue_forPropertyName_inMetaDictionaryName(newName, kCGImagePropertyIPTCObjectName, kCGImagePropertyIPTCDictionary);
            }
    else {
        console.log("Missing underscore in " + fileName)
    }
    
    return true;
}

Let me know how it works out!


#5

Wow!

This worked perfectly the first time I tried it.
The workflow does exactly what I wanted!
This is so cool!

THANKS!!!