home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Postcards / createPostcard.cgi next >
Text File  |  2017-09-21  |  2KB  |  88 lines

  1. #!/user/a61/perl/bin/perl
  2. # #!/usr/local/bin/perl
  3.  
  4. use GD;
  5.  
  6. # initialize
  7. $input_postcard="pictures/postcard.gif";
  8. $extension=".gif";
  9. $note = "The Internet 1996 World Exposition";
  10. $note2 = "http://park.org/";
  11.  
  12.  
  13. # Read arguments from command line
  14. # make inputs
  15. if ($#ARGV == 1) {
  16.    $message_input = @ARGV[0];
  17.    $postcard_input = @ARGV[1];
  18. }
  19. else {
  20.    print "Usage: createPostcard.cgi [MESSAGE POSTCARD]\n";
  21.    exit(0);
  22. $input_text="$message_input";
  23. $input_picture="pictures/$postcard_input";
  24. $input_picture=$input_picture.$extension;
  25.  
  26.  
  27. # Read empty postcard
  28. if ( open (IMIN1, "$input_postcard") ) {
  29.    $postcard = newFromGif GD::Image(IMIN1);
  30.    close (IMIN1);
  31. }
  32. else {
  33.    exit 0;
  34. }
  35.  
  36.  
  37. # Read picture to put in postcard
  38. if ( open (IMIN2, "$input_picture") ) {
  39.    $picture = newFromGif GD::Image(IMIN2);
  40.    close (IMIN2);
  41. }
  42. else {
  43.    exit 0;
  44. }
  45.  
  46.  
  47. # Colors
  48. $white = $postcard->colorAllocate(255,255,255);
  49. $black = $postcard->colorAllocate(0,0,0);
  50. $bg_color = $black;
  51.  
  52. # Change Background
  53. $postcard->fill(25,25,$bg_color);
  54.  
  55.  
  56. # Place the text
  57. # - 25 grote karakters passen binnen 200 pixels
  58. # - Dit is 8 pixels per groot karakter
  59. if ( ! ($input_text eq "No") ) {
  60.    $Large_Length=50;
  61.    $Large_Pixel=8;
  62.  
  63.    # - string: font, destX, destY, string, color
  64.    # - font: gdSmallFont, gdLargeFont, gdMediumBoldFont (12pt), gdTinyFont
  65.    $input_text =~ tr/_/ /;
  66.    $length_text = length($input_text);
  67.    $length_diff = $Large_Length - $length_text;
  68.    $length_diff = int($length_diff / 2);
  69.    $offset = ( $length_diff * $Large_Pixel ) - 1;
  70.    $postcard->string(gdLargeFont, 50 + $offset, 44, $input_text, $white);
  71. }
  72.  
  73.  
  74. # A note
  75. $postcard->string(gdMediumBoldFont, 132, 229, $note, $white);
  76. $postcard->string(gdMediumBoldFont, 194, 247, $note2, $white);
  77.  
  78.  
  79. # Place the picture
  80. ($picture_width, $picture_height) = $picture->getBounds();
  81. $postcard->copyResized($picture, 125, 100, 0, 0, 250, 100, $picture_width, $picture_height);
  82.  
  83.  
  84. # output
  85. print "Content-Type: image/gif\n\n";
  86. print $postcard->gif;
  87.