Steve's Photography Tips: Adding a Watermark with ImageMagick

A Morning Fog

A foggy morning view down the driveway at our house, with a watermark added using ImageMagick

A light fog settles in around the trees of our front yard on a recent morning, although the fog did not stick around for long. The watermark on this photo was added using ImageMagick. Read more about that farther down in this post.

Our crepe myrtle trees are rather late bloomers, as they usually wait until well past mid-July to begin blooming. But it is worth the wait, as you can see here from the trees in the foreground just past the post light.

I suppose this photo would have been even more interesting if I had turned on that post light. But it was probably too light outside for the photocell in the light to actually turn the light on, so I did not bother trying. That would have added a little more interest to the photo.

If you are wondering, this is the same morning fog that produced the previously posted photos Spider Web and Dew and Barn in the Fog. As you can see, it was a good morning for photos.

Adding a Watermark with ImageMagick

You may have noticed the Burnsland watermark in the lower-left corner of the photos that I share here. If you have ever wondered how that was done, here is your answer.

This actually follows up on last week’s Steve’s Photography Tips post about resizing images with ImageMagick. That same handy utility can also be used to add a watermark.

But first, you need to have a watermark file to add to your photo. After some experimentation, I decided that the size that would work best for me is about 340x100 pixels. You may want something larger or smaller. This size works best with the photos that I resize to the dimensions mentioned in the previous post. If you are going to keep your photos large, you might want to use some larger dimensions for your watermark.

I chose to have my watermark file as a PNG format, because unlike a JPG, that allows you to have a transparent background, so that you only see the text of the watermark and not a solid box. A JPG file would probably work as well, but see the notes below about why you probably don’t want to use that. Some programs like Photoshop can save a PNG file. Or you might try Inkscape, an open source drawing program.

As before, a simple .bat file will make this work in Windows. The code for adding a watermark is quite easy:

magick mogrify -gravity southwest -draw "image over 0,10 0,0 bl-logo.png" *.jpg

Using Notepad or some similar text editor, copy the code above into a file and name it something like “watermark.bat” or whatever works for you. Change the filename from “bl-logo.png” to the name of your watermark file. A couple of notes about the ImageMagick commands:

  • -gravity southwest: This puts the watermark in the lower-left corner. If you want the lower right corner, use “-gravity southeast”. Or northwest and northeast for the upper corners. If you want it centered in the bottom, just use south. And north for the top.

  • 0,10 0,0: These coordinates set the location of the watermark image. The first set is the x,y coordinates where the image will start. My watermark was too close to the bottom of the image, so I moved it up 10 pixels. The second set of numbers is the image size, which can just be left to 0,0.

A few other notes:

  • The code line above just by itself will overwrite the original image, just so you know. More on that in just a minute.

  • As with the other, this will place the watermark on every JPG file in the folder. Therefore, it is best to have a PNG or GIF as your watermark file, because otherwise it will try to add the watermark to the watermark. That’s not good.

Now, let’s put that together with what we talked about last time, so that with one click your photo (or photos if you have several) will be resized, renamed, watermarked, and moved to a subfolder. Here is what that code would look like:

magick convert *.jpg -strip -interlace Plane -resize "1920x1280>" -quality 85 -modulate 100,130,100 -set filename:fname %%t_small +adjoin %%[filename:fname].jpeg
magick mogrify -path wm -format jpg -interlace Plane -gravity southwest -draw "image over 0,10 0,0 bl-logo.png" *.jpeg
DEL *.jpeg

As with the code in the previous post, with the code above your original photo would stay intact. A new .jpeg copy would be created during resizing. This would then be renamed, have the watermark added to it, and then moved to the “wm” subfolder. Feel free to change names of subfolders, watermark files, and even the added name at the end of the filename to whatever suits you.

Once again, you can see that ImageMagick is quite an amazing tool to be used! Check back later for a few more ImageMagick tips, and see Steve’s Photography Tips for more!

Bible Verse

Give, and it will be given to you. Good measure, pressed down, shaken together, running over, will be put into your lap. For with the measure you use it will be measured back to you. - Luke 6:38

About the Photo

As you probably read above, the photo was taken while looking down our driveway on a foggy morning. You may be able to guess this already, but foggy photos are usually, well, foggy, for lack of a better term. I used Aurora HDR to give a slightly less foggy look to this photo, increasing the color saturation and contrast somewhat, although you can still definitely see the fog in the background.

Photo: A single Raw exposure, processed in Luminar. Read more about photography tips, photo software, camera gear, and more at Steve’s Photography Tips.
Camera: Sony Alpha A7 II
Lens: Sony FE 50mm f/1.8
Date: August 5, 2019
Location: Home, Williston, Tennessee


World Bible School

Burnsland Email

Burnsland avatar
Burnsland is Steve Burns, with generous help from his lovely wife Laura. Steve is a husband, father, photographer, webmaster, writer, podcaster, artist, Christian. Steve enjoys sharing his photography, art, and stories through Burnsland.com, from the Burnsland World Headquarters in Tennessee.