home *** CD-ROM | disk | FTP | other *** search
- #!/user/a61/perl/bin/perl
- # #!/usr/local/bin/perl
-
- use GD;
-
- # initialize
- $input_postcard="pictures/postcard.gif";
- $extension=".gif";
- $note = "The Internet 1996 World Exposition";
- $note2 = "http://park.org/";
-
-
- # Read arguments from command line
- # make inputs
- if ($#ARGV == 1) {
- $message_input = @ARGV[0];
- $postcard_input = @ARGV[1];
- }
- else {
- print "Usage: createPostcard.cgi [MESSAGE POSTCARD]\n";
- exit(0);
- }
- $input_text="$message_input";
- $input_picture="pictures/$postcard_input";
- $input_picture=$input_picture.$extension;
-
-
- # Read empty postcard
- if ( open (IMIN1, "$input_postcard") ) {
- $postcard = newFromGif GD::Image(IMIN1);
- close (IMIN1);
- }
- else {
- exit 0;
- }
-
-
- # Read picture to put in postcard
- if ( open (IMIN2, "$input_picture") ) {
- $picture = newFromGif GD::Image(IMIN2);
- close (IMIN2);
- }
- else {
- exit 0;
- }
-
-
- # Colors
- $white = $postcard->colorAllocate(255,255,255);
- $black = $postcard->colorAllocate(0,0,0);
- $bg_color = $black;
-
- # Change Background
- $postcard->fill(25,25,$bg_color);
-
-
- # Place the text
- # - 25 grote karakters passen binnen 200 pixels
- # - Dit is 8 pixels per groot karakter
- if ( ! ($input_text eq "No") ) {
- $Large_Length=50;
- $Large_Pixel=8;
-
- # - string: font, destX, destY, string, color
- # - font: gdSmallFont, gdLargeFont, gdMediumBoldFont (12pt), gdTinyFont
- $input_text =~ tr/_/ /;
- $length_text = length($input_text);
- $length_diff = $Large_Length - $length_text;
- $length_diff = int($length_diff / 2);
- $offset = ( $length_diff * $Large_Pixel ) - 1;
- $postcard->string(gdLargeFont, 50 + $offset, 44, $input_text, $white);
- }
-
-
- # A note
- $postcard->string(gdMediumBoldFont, 132, 229, $note, $white);
- $postcard->string(gdMediumBoldFont, 194, 247, $note2, $white);
-
-
- # Place the picture
- ($picture_width, $picture_height) = $picture->getBounds();
- $postcard->copyResized($picture, 125, 100, 0, 0, 250, 100, $picture_width, $picture_height);
-
-
- # output
- print "Content-Type: image/gif\n\n";
- print $postcard->gif;
-