One of my niece need help to watermarking her photo so she can put on her facebook page and ask me how to do that on linux. Yeah, of course my first thought is gimp 🙂 it’s easy to give a transparent watermark text and then blend or overlaying the two image to produce the merging image. But since the image is a plenty of them I began to think this is not fun to do this one by one. 🙂 The second thought had in mind is using Imagemagick, digging on the manual and the web I found the composite command which is part of ImageMagick package that can do this pretty easy. ImageMagick was default in KLIXs installation, so the composite command should be on the system.
First, I create the watermark image using gimp, just a simple text www.jfdesignnet.com, rearrange the position, text color and size, removing the background layer and save it as watermark.png at the same folder as the jpeg image and execute this command within the path :
{code}composite -gravity northeast -quality 90 -dissolve 50 watermark.png image.jpg newimage.jpg{/code}
The gravity option means the image and the watermark will be combined with corresponding top-right corners. The quality option specifies the resulting quality for the output image, in this case 90% jpeg. The dissolve option specifies, in this example, 50% transparency. Lower values will make the watermark appear fainter.
For other options on the composite command, see the composite man page.
There you go, the result image is like this :
Now it’s time to create some simple batch process so we can do this watermarking to a lot of image in a folder :
{code}find . -name “*jpg” -type f -exec composite -gravity northeast -quality 90 -dissolve 50 watermark.png {} {} ;{/code}
I’m working with all jpg files here, but of course you can change the file type with gif or png. And, since I overwriting the original jpeg image with results image, so make sure you already have a backup all the jpegs in the current directory before doing this so you can restore them if you’re not happy with the result.
And … ooh, for some reason I think you will gonna need the resize batch process also to resizing the image into web image resolution. 🙂 The mogrify tool from ImageMagick will come in handy for this purpose, and here is the command :
{code}mogrify -resize 640 *.jpg{/code}
That command will resize all image in folder into 640 width and keep the aspect ratio. Of course you can force the resolution to fixed value, and here is how to do :
{code}mogrify -resize 640×480! *.jpg{/code}
For other options on the mogrify command, see the mogrify man page.
Happy watermarking 🙂