One of the most boring, tedious tasks I’ve seen adult performers complain about is watermarking pics to prevent others stealing their pics. To me, this sounded like an interesting problem and an excellent excuse to try my hand at programming. I’d started to use BAT scripts at work, so I wanted to see if I could solve this problem using BAT script programming. I believe I’ve succeeded!

This script will take photos you save to your DropBox, either from your desktop or via mobile pics, and batch watermark them, place them in a separate folder, then save the original pic in an Archive folder. If you have the script scheduled to run every few minutes, you can take a pic on your phone, save it to your DropBox, then have a watermarked photo available in your DropBox minutes later!

To get this to run correctly, you’ll need to install the following programs:
DropBox
ImageMagick
Notepad++

Install these programs, setup your Dropbox account, and proceed.

Note: After installing DropBox, go to c:\program files\ImageMagick-6.7.9-Q16 and right click on the file called “composite”, then select “Properties”. Go to the “Compatibility” tab and enable compatibility with Windows XP.

Ok, we’re ready to set up our script. Follow these steps to set it up:

Step 1) Go to your DropBox folder. It should be located somewhere like c:\Users\YOURUSERNAME\Dropbox  In this folder, create the following sub directories by clicking on “New Folder”:

“temp”, “Archive”, “Final”, “CameraUploads” and “data”

Now you should have 4 new folders named c:\Users\YOURUSERNAME\Dropbox\temp c:\Users\YOURUSERNAME\Dropbox\Archive c:\Users\YOURUSERNAME\Dropbox\Final and c:\Users\YOURUSERNAME\Dropbox\data

Step 2) Go to c:\Users\YOURUSERNAME\Dropbox\data and drop your watermark there. The watermark should be named water.jpg

Step 3) Next, open up Notepad++. First, click the “Language” button at the top of the window, and select “BATCH”. Next, Copy and paste the following code:

@ echo off
cls
:start
set /a counter=%counter%+1
IF EXIST C:\Users\YOURUSERNAME\Dropbox\CameraUploads\*.jpg REN C:\Users\YOURUSERNAME\Dropbox\CameraUploads\*.jpg scratch%counter%.jpg
IF NOT EXIST C:\Users\YOURUSERNAME\Dropbox\CameraUploads\*.jpg EXIT
IF EXIST C:\Users\YOURUSERNAME\Dropbox\CameraUploads\scratch%counter%.jpg MOVE C:\Users\YOURUSERNAME\Dropbox\CameraUploads\scratch%counter%.jpg C:\Users\YOURUSERNAME\Dropbox\temp
composite -gravity SouthEast C:\Users\YOURUSERNAME\Dropbox\data\water.jpg scratch%counter%.jpg Final%counter%.jpg
IF EXIST Final%counter%.jpg MOVE C:\Users\YOURUSERNAME\Dropbox\temp\Final%counter%.jpg C:\Users\YOURUSERNAME\Dropbox\Final
for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "C:\Users\YOURUSERNAME\Dropbox\Final\Final%counter%.jpg" %%d-%%e-%counter%-final.jpg
IF EXIST scratch%counter%.jpg MOVE C:\Users\YOURUSERNAME\Dropbox\temp\scratch%counter%.jpg C:\Users\YOURUSERNAME\Dropbox\Archive
for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "C:\Users\YOURUSERNAME\Dropbox\Archive\scratch%counter%.jpg" %%d-%%e-%counter%-original.jpg
goto start

Step 4) Press Ctrl+H to bring up the Search and Replace window. Enter YOURUSERNAME as the “Find What” variable, and enter your Dropbox username as the Replace With variable. Then click “Replace All”

Step 5) Next, save the file using “Save As”, and put the BAT file in c:\Users\YOURUSERNAME\Dropbox\temp

Step 6) Drop a few jpgs into \CameraUploads and try running the BAT file. To run the file, simply double click on it. It should put a watermark on all the pictures and put them into the \Final folder, then put the original images into \Archive.

Step 7) The last step, which will make the process truly “Automagic”, is to set the BAT script to run regularly using the Task Scheduler. For this, go to Start -> Control Panel -> Administrative Tools -> Task Scheduler. From there, you can set the BAT script to run every 5 min, 10 min, etc.

That’s it! You should be all done. If you want to change anything with the image as it’s being processed, check out the command line options available at ImageMagick

Test Run:

This is my Watermark

This is my Source Image

This is the final, watermarked image

Advertisements