I'm getting a 500 Internal Server error with this script, any ideas?
#!/usr/bin/perl
use GD;
use strict;
use warnings;
&jpg_resize();
print "Content-type: text/html\n\n";
print "<html><body>Done</body></html>";
exit();
sub jpg_resize
{
#settings--------------------------------------
my $sourcefile = "oldpic.jpg";
my $targetfile = "newpic.jpg";
my $jpeg_quality = 60; #Quality
my $max_sizex = 220; #max picturewith
my $max_sizey = 220; #max pictureheight
#----------------------------------------------
$sourcefile = shift();
$targetfile = shift();
GD::Image->trueColor(1); #improves quality
my $bildle = newFromJpeg GD::Image($sourcefile, 1) || die "could not open image."; #Bild öffnen...
#find size-------------------------------------
(my $width, my $height) = $bildle->getBounds(); #Maße herausfinden...
if ($width > $height)
{$max_sizey = $height / ($width / $max_sizex);}
else
{$max_sizex = $width / ($height / $max_sizey);}
#create new picture (thumbnail)
my $bild=newTrueColor GD::Image($max_sizex,$max_sizey);
$bild->copyResized($bildle,0,0,0,0,$max_sizex,$max_sizey,$width,$height);
$bild->interlaced('true');
#save the new picture...
open(DATEI ,">$targetfile") || die "could not write image: $!";
binmode DATEI;
print DATEI ($bild->jpeg($jpeg_quality));
close(DATEI);
return('true');
}
#!/usr/bin/perl
use GD;
use strict;
use warnings;
&jpg_resize();
print "Content-type: text/html\n\n";
print "<html><body>Done</body></html>";
exit();
sub jpg_resize
{
#settings--------------------------------------
my $sourcefile = "oldpic.jpg";
my $targetfile = "newpic.jpg";
my $jpeg_quality = 60; #Quality
my $max_sizex = 220; #max picturewith
my $max_sizey = 220; #max pictureheight
#----------------------------------------------
$sourcefile = shift();
$targetfile = shift();
GD::Image->trueColor(1); #improves quality
my $bildle = newFromJpeg GD::Image($sourcefile, 1) || die "could not open image."; #Bild öffnen...
#find size-------------------------------------
(my $width, my $height) = $bildle->getBounds(); #Maße herausfinden...
if ($width > $height)
{$max_sizey = $height / ($width / $max_sizex);}
else
{$max_sizex = $width / ($height / $max_sizey);}
#create new picture (thumbnail)
my $bild=newTrueColor GD::Image($max_sizex,$max_sizey);
$bild->copyResized($bildle,0,0,0,0,$max_sizex,$max_sizey,$width,$height);
$bild->interlaced('true');
#save the new picture...
open(DATEI ,">$targetfile") || die "could not write image: $!";
binmode DATEI;
print DATEI ($bild->jpeg($jpeg_quality));
close(DATEI);
return('true');
}