How to make watermarks in Perl

Published: 03-Feb-2011 (18:03); Viewed: 8378; Difficulty: 1 out of 10

Rating: 5.33333/10 based on 3 votes.

k

How to make watermarks in Perl
For many purposes it is very important to place small, semitransparent phrase, name, or logo into a big image. Usually it is very important for website owners, to label their images to prevent, or reduce inappropriate copying. This How To give you essential knowledge, about simplest way to do it with Perl scripts.

step-by-step instructions

  1. You should prepare your image with logo. We can advise you to do something not very big and not very colorful. Also we will recommend to use transparent background for this image. Preferably this image should be smaller than any of your images you want to mark.

  2. Copy this program into your Perl script:

    use Image::Magick;
    # initiate Image::Magick objects for your images
    my $img = Image::Magick->new;
    my $logo = Image::Magick->new;

    # read image for marking and watermark
    $from->Read("image-from.jpg");
    $logo->Read("logo.gif");

    # blend two images
    $foto->Composite
    (
    compose=>'blend',
    blend=>'50x50',
    x=>'50', y=>'50',
    image=>$logo,
    );

    # save final result
    $img->Write("image-to.jpg");

  3. Run your Perl script and enjoy

  4. For better appearance, you can play with blend=>'50x50' parameter for better balance between logo and image

  5. Find the best placement of watermark logo with x=>'50', y=>'50' parameters.

  6. For placement of your logo in the center of the image you either can accurately calculate coordinates, or use parameter gravity=>'Center' instead of x=>'50', y=>'50' parameters.



Rate:
1 2 3 4 5 6 7 8 9 10
by: John Farnon
Delicious submit to reddit Add to Technorati Favorites
tags: graphic library; perl; script

also read


navigation:officials:topics:
  • copyright
  • privacy
  • contacts