In trying to understand the basics of creating thumbnails using GD.pm. I found a simple script that I copied and called thumbnail.cgi(CHMOD755), the code seemed to make sense.
So I placed a jpg file directly into the cgi folder(CHMOD755) and I plugged in the src file name and nothing happens. Not even a print statement, just a blank white page.
I am very frustrated. I just wanted to see how the thumbnail creation works.
Thanks for your time
Cal
In the begining
Let us first assume that there was nothing to begin with.
So I placed a jpg file directly into the cgi folder(CHMOD755) and I plugged in the src file name and nothing happens. Not even a print statement, just a blank white page.
I am very frustrated. I just wanted to see how the thumbnail creation works.
Thanks for your time
Cal
Code:
#!/usr/local/bin/perl
use GD;
print "Content-type: text/html\n\n";
my $maxheight = 100;
my $maxwidth = 100;
my $srcimage = GD::Image->newFromJpeg("churchmiddle.jpg");
my ($srcW,$srcH) = $srcimage->getBounds();
my $wdiff = $srcW - $maxwidth;
my $hdiff = $srcH - $maxheight;
my $newH; my $newW;
if ($wdiff > $hdiff) {
$newW = $maxwidth;
$aspect = ($newW/$srcW);
$newH = int($srcH * $aspect);
} else {
$newH = $maxheight;
$aspect = ($newH/$srcH);
$newW = int($srcW * $aspect);
}
print "converting $srcW:$srcH to $newW:$newH\n";
my $newimage = new GD::Image($newW,$newH);
$newimage->copyResized($srcimage,0,0,0,0,$newW,$newH,$srcW,$srcH);
open(FILE, ">test.jpg") || die "Cannot open churchmiddle.jpg: $!\n";
print FILE $newimage->jpeg;
Let us first assume that there was nothing to begin with.