#!/usr/bin/perl -w # # This Perl-Fu GIMP plug-in script adds a "transparent" bump-mapped watermark # of a user-specified text string to an image. # # Nadim Nakhleh 3/17/01 # use Gimp qw(:auto N_); use Gimp::Fu; use Gimp::Util; # Register plug-in register("watermark_signature", "Adds a \"transparent\" bump-mapped watermark of a user-specified text string to an image.", "Sorry buddy...I can barely help myself right now...", "Nadim Nakhleh", "(c) Nadim Nakhleh", "3/17/01", N_"/Script-Fu/Decor/Watermark Signature...", "*", [ [ PF_FONT, "font", "Font Name", "-*-helvetica-bold-r-normal-*-*-*-*-*-p-*-iso8859-1" ], [ PF_STRING, "text", "Enter the text to be signed", "www.nakhleh.net"], [ PF_RADIO, "location", "Select watermark location", 3, [ "bottom left" => 1, "bottom_center" => 2, "bottom_right" => 3 ] ], ], [PF_IMAGE], \&do_watermark_signature); sub do_watermark_signature { my($img, $drw, $font, $text, $location) = @_; my($txtlayer, $finallayer, $xoffset, $yoffset); my($lwidth, $lheight); # Generate new dynamic text layer $txtlayer = plug_in_dynamic_text(RUN_NONINTERACTIVE, $drw, # Pass in drawable $text, # Pass in text string 1, # Set anti-aliasing ON 1, # Set alignment to CENTER 0, # Set rotation to 0 0, # Set line-spacing to 1 [255, 255, 255], # Set color to WHITE $location, # Pass in location $font); # Pass in font # Add a little buffer around the dynamic text layer...it tends to cut it # too close on the top and left sides $lwidth = gimp_drawable_width($txtlayer); $lheight = gimp_drawable_height($txtlayer); gimp_layer_resize($txtlayer, $lwidth + 4, $lheight + 4, 4, 4); # Get bump map layer offsets, as the non-interactive bump map command doesn't # seem to want to calculate them for me automatically ($xoffset, $yoffset) = gimp_drawable_offsets($txtlayer); $xoffset *= -1; $yoffset *= -1; # Bump map original layer with text layer plug_in_bump_map(RUN_NONINTERACTIVE, $drw, # Pass in drawable $txtlayer, # Pass in text layer for bump map 135, # Azimuth 45, # Elevation 3, # Depth $xoffset, # X offset $yoffset, # Y offset 0, # Waterlevel 0, # Ambient 1, # Compensate for darkening 0, # Don't invert 0); # Use LINEAR map # Drop opacity on text layer to 10% (so you can still something in dark regions) gimp_layer_set_opacity($txtlayer, 10); # Flatten the result gimp_image_flatten($img); # Return the image return $img; } exit main;