#! /usr/bin/perl -w # # $Id$ # Copyright (c) 2007 patrick keshishian use strict; use GD; # global vars my $self = `basename $0`; chomp($self); # proto-sub my ($wm_file, $src_file, $out_file); my ($iw, $is, $io); my ($dx, $dy, $sx, $sy, $sw, $sh); # set-up $wm_file = 'circ.png'; $src_file = 'test_in.jpg'; $out_file = 'gd_blend_test.jpg'; GD::Image->trueColor(1); # open source image $is = GD::Image->new($src_file) or die(sprintf("Failed to open \"%s\"", $src_file)); # open watermark image $iw = GD::Image->new($wm_file) or die(sprintf("Failed to open \"%s\"", $wm_file)); # Blending $dx = 100; $dy = 5; $sx = 115; $sy = 47; $sw = $sh = 295; $is->blend($iw, $dx, $dy, $sx, $sy, $sw, $sh, 100); $is->string(gdLargeFont, $dx, $dy + $sh * 0.9, '100%', 0xffffff); $is->rectangle($dx, $dy, $dx + $sw, $dy + $sh, 0x60ffffff); $is->blend($iw, $dx + $sw, $dy, $sx, $sy, $sw, $sh, 65); $is->string(gdLargeFont, $dx + $sw, $dy + $sh * 0.9, '65%', 0xffffff); $is->rectangle($dx + $sw, $dy, $dx + $sw * 2, $dy + $sh, 0x60ffffff); $is->blend($iw, $dx, $dy + $sh, $sx, $sy, $sw, $sh, 35); $is->string(gdLargeFont, $dx, $dy + $sh * 1.1, '35%', 0xffffff); $is->rectangle($dx, $dy + $sh, $dx + $sw, $dy + $sh * 2, 0x60ffffff); $is->blend($iw, $dx + $sw, $dy + $sh, $sx, $sy, $sw, $sh, 10); $is->string(gdLargeFont, $dx + $sw, $dy + $sh * 1.1, '10%', 0xffffff); $is->rectangle($dx + $sw, $dy + $sh, $dx + $sw * 2, $dy + $sh * 2, 0x60ffffff); # open destination/out file for writing open(OUT, ">$out_file") or die(sprintf("Failed to write \"%s\": %s", $out_file, $!)); # write out resulting image print(OUT $is->jpeg(70)); close(OUT);