tad91030
asked on
Perl GD Image manipulation problem
Im running windows 2000 server with active perl installed.
Im trying to create a small app that takes a jpg image and copys it 4 times mergin into one image.
And makes a thumbnail of the image.
I am getting weird results...
Original image
http://www.thespenceroutfit.com/cgi-bin/Flyer/Test2.jpg
http://www.thespenceroutfit.com/cgi-bin/Flyer/Flyer.cgi
use GD;
my $maxheight = 350;
my $maxwidth = 350;
my $srcimage = new GD::Image->newFromJpeg("Te st2.jpg") || die;
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);
}
$BigH = ($srcH * 2);
$BigW = ($srcW * 2);
my $newimage = new GD::Image($BigW,$BigH) || die;
$newimage->copy($srcimage, 0,0,0,0,$s rcW,$srcH) ;
$newimage->copy($srcimage, $srcW,$src H,0,0,$src W,$srcH);
# code for thumbnail $newimage->copyResized($sr cimage,0,0 ,0,0,$newW ,$newH,$sr cW,$srcH) ;
open(FILE, ">index1.jpg") || die "Cannot open index1.jpg: $!\n";
print FILE $newimage->jpeg(80) ;
close FILE;
print '<br><br><img src="http://www.thespenceroutfit.com/cgi-bin/Flyer/index1.jpg">';
exit;
Im trying to create a small app that takes a jpg image and copys it 4 times mergin into one image.
And makes a thumbnail of the image.
I am getting weird results...
Original image
http://www.thespenceroutfit.com/cgi-bin/Flyer/Test2.jpg
http://www.thespenceroutfit.com/cgi-bin/Flyer/Flyer.cgi
use GD;
my $maxheight = 350;
my $maxwidth = 350;
my $srcimage = new GD::Image->newFromJpeg("Te
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);
}
$BigH = ($srcH * 2);
$BigW = ($srcW * 2);
my $newimage = new GD::Image($BigW,$BigH) || die;
$newimage->copy($srcimage,
$newimage->copy($srcimage,
# code for thumbnail $newimage->copyResized($sr
open(FILE, ">index1.jpg") || die "Cannot open index1.jpg: $!\n";
print FILE $newimage->jpeg(80) ;
close FILE;
print '<br><br><img src="http://www.thespenceroutfit.com/cgi-bin/Flyer/index1.jpg">';
exit;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.