#! /usr/bin/perl -w # # $Id$ # Copyright (c) 2007 patrick keshishian use strict; use GD; # global vars my $self = `basename $0`; chomp($self); # proto-sub sub main(); # main main(); exit(0); # subs sub main() { my ($wm_file, $src_file, $out_file); my ($iw, $is, $io); # set-up $wm_file = 'circ.png'; $src_file = 'test_in.jpg'; $out_file = 'test_out_v0.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)); printf("iw->trueColor() = %d$/", $iw->trueColor()); printf("is->trueColor() = %d$/", $is->trueColor()); # copy watermark onto source image $is->copy($iw, 50, 50, 0, 0, $iw->width, $iw->height); # 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); exit(0); }