We have been to a jungle resort over the weekend and took some good quality pictures. I wanted to watermark a few of them and then post it on a photo sharing site. Being a scripting fanatic and PowerShell lover, I wanted to see if I can achieve this using a PowerShell script. And, here is the result
Before watermarking
After watermarking
I used System.Drawing namespace to achieve this. You can download this script here
After you dot-source the downloaded script, you can start watermarking images by running the following command
Watermark-Image -Source “C:\Images” -Destination “C:\WaterMarkedImages” -text “All rights reserved”
As you see in the above sample pictures, watermark text will be black color. You can modify the same by changing the following line in the script
$color = [System.Drawing.Color]::FromArgb(153, 0, 0,0)
The position of watermark will be the top-left corner. You can change that by specifying the pixel positions in the following line
$gImg.DrawString($text,$font,$myBrush,0,100)
Also, I am not taking care of output image format. It will always be JPEG. We can add that support as well by looking at the source extension. I will do that in a future release. We can extend this script to take out all above assumptions and capture everything from user input. This script is just a demonstration of what we can do using System.Drwaing namespace in PowerShell.
BTW, that is my son Kaustubh in the photograph.

{ 2 comments… read them below or add one }
Excellent, just what I needed, I adapted it for the text to be centered and I had it read from a database, the result was instant greatness. Thanks.
Glad it helped..!
{ 1 trackback }