#!/usr/local/bin/perl -wT # Change above line to path to your perl binary ##---------------------------------------------------------------------------## ## Author: ## Pradeep Padala, ppadala@cise.ufl.edu ## Description: ## Program to create a small online photo album ##---------------------------------------------------------------------------## ## Copyright (C) 2002 Pradeep Padala, ppadala@cise.ufl.edu ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##---------------------------------------------------------------------------## use CGI ':standard'; use GD; $imnum = param('imnum'); if(!defined($imnum)) { $imnum = 0; } $orig = param('orig'); if(!defined($imnum)) { $orig = 0; } select(STDOUT); $| = 1; @images = ("surfing.jpg", "boat.jpg", "boston-view.jpg", "seashore.jpg"); print "Content-type: text/html\n\n"; print "Click on the image to make it bigger or smaller
You can browse through the small images using the buttons or by clicking on the numbers
\n"; print "\n"; if($imnum > 0 && $imnum < @images) { printf "
\n", $imnum-1; } if($imnum >= 0 && $imnum < @images - 1) { printf "\n", $imnum+1; } print ""; for($i = 0; $i < @images; ++$i) { print "$i|\n"; } print "
\n"; if($imnum < 0 || $imnum >= @images) { print "No such image"; exit; } if($orig) { print "\n"; } else { $im = GD::Image->newFromJpeg("images/$images[$imnum]"); # create a new image ($width, $height) = $im->getBounds(); $newwidth = 200; $newheight = 200; $outim = new GD::Image($newwidth, $newheight); $outim->copyResized($im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $tmpfile = "images/tmp$imnum.jpg"; open(TMP, ">$tmpfile") || die("Cannot open file"); binmode(TMP); print TMP $outim->jpeg(100); close(TMP); chmod(0644, $tmpfile); print ""; }