Lilypie Fourth Birthday tickers

May 14, 2008

Creating digital watermarking for your photos

I just took some pictures from Phuket using my new Canon 450D digital SLR. To let my wife to present the pictures online, I think it is better to create the digital watermarking for the pictures for copyright purpose.

There are many softwares available out there, but I was wondering if I could do it myself easily. After some research and goggling, I think I can just use Perl to process all my photos at once with the help of the ImageMagick since I have it installed in my Vista Premium already.

Here are the simple steps to produce the watermark photos:
  1. Install Gimp or Photoshop or any image processing software to create your own digital watermark such as the following:


  2. Install ActivePerl in your Windows OS. If you are using Linux/Unix, you may already have it installed.
  3. Install ImageMagick.
  4. Then copy the following perl script using a text editor to a file named "transfer.pl".

    #!/usr/bin/perl -w

    #Change your settings here
    $targetFolder = "converted";
    $targetFilePattern = "conv";
    $watermark = "C:\\Temp\\watermark.png";
    $imageExt = "JPG";


    $i = 1;

    opendir(DIR, ".");
    @files = grep(/\.$imageExt$/,readdir(DIR));
    closedir(DIR);

    mkdir($targetFolder);
    foreach $file (@files) {
    $targetFile = "$targetFolder\\$targetFilePattern".($i++).".$imageExt";
    $cmd = "composite -dissolve 50% -gravity SouthEast -geometry +5+5 $watermark $file $targetFile";
    print "Converting $file to $targetFile\n";
    system($cmd);
    }

  5. Change the setting in the script, e.g. target folder name, target file pattern, watermark picture file location and the source photo file type.
  6. Copy the file to your folder which contains the photos to convert and execute it by "perl transfer.pl".
Here is the final result:

No comments: