I use GIMP. It does the job quite well for most things but I felt a bit robbed (of my $0) when I found out there was no watermark tool, especially one that works in bulk. After trying to search around I did find a watermark python script that worked on basic terms at the Gimp Plugin Registry. However I believe it was limited to text and had some features I really wanted.
I decided to try to learn ‘script-fu’. I’ve got to say it was the roughest coding experience I’ve had in awhile. Even the GIMP batch tutorial leaves a lot to be explained, and it didn’t even work for me without trial and error on the batch command! Don’t get me started on how the code was laid out.
Regardless, you’re likely here just to get what you need done. Lets start.
- Download my script, here’s a link.
- Save this file to your GIMP install followed by \share\gimp\2.0\scripts. GIMP is often found under Program Files (for those Windows users like me). While you’re there, why not open up the file and take a look at my hard work and imagine the alcohol needed to fuel that.
- I did not put time into writing a fancy interface. This script is best run from command line. For Windows users Start -> Run… -> Cmd (hit OK) will do the trick.
- Type cd followed by your GIMP directory (i.e. cd “C:\Program Files\GIMP 2\bin”)
OK take a break for one second and see what my command lets you define:
Watermark Path – Path to a watermark in XCF (GIMP) format. Other formats may work as well.
Input files – Path to directory, followed by a wildcard search (i.e. *.jpg to target all jpg images to be watermarked).
Watermark Size – How big your watermark will be in accordance to the image. This is a percent but is entered as a decimal such as .05 (5%).
Watermark Padding – Each watermark will be padded from the corners of the image by a percentage (of the entire image) you define. This is a percent but is entered as a decimal as well.
Watermark Layer Mode – leave this as 0 (zero). higher numbers (i.e. 1,2,3…) will enable a different layer mode such as lighten/hard light/etc.
Position Number – My script allows for the watermark to be aligned in any corner, or the center. Acceptable values are 1,2,3,4,5.
Output Path – Where the watermarked images will be saved to.
- Any paths defined should be enclosed in quotes. These quotes should be preceded by a backslash with no space. I.e. C:\Mike in the script would become \”c:\\mike\”. Any other backslashes MUST ALSO be preceded by a backslash (as seen between c: and mike).
- Output path must be a directory. Do not leave a trailing slash on this.
So. You want to run THIS!
gimp-2.8.exe -b "(migee-add-watermark watermark-path inputfiles watermark-size watermark-padding watermark-layer-mode position output-dir)"
This is what I had to do to run my script on a folder WatermarkTest in my desktop on every JPG, having the watermark sized 25% and padded 1% along with a layer effect (15) and centered (5). Outputted files went to the same directory (the script prefixes all file names).
gimp-2.8.exe -b "(migee-add-watermark \"C:\\Users\\Migee\\Desktop\\WatermarkTest\\watermark.xcf\" \"C:\\Users\\Migee\\Desktop\\WatermarkTest\\*.jpg\" .25 .01 15 5 \"C:\\Users\\Migee\\Desktop\\WatermarkTest\")"
Windows users, typing these the commands into a text file with the extension .BAT will save time if you do this a lot. It’s not easy with all the double slashes and slashed file location quotes.
This has HARDLY been tested and was really just completed to see if I could do this or not. I did little testing aside from the few images and singular watermark I’ve been working with. Please post up any problems and I can see if I can make this script work better!
Have improvements? Check out the code on GitHub