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

use GD;
my $maxheight = 350;
my $maxwidth = 350;
my $srcimage = new GD::Image->newFromJpeg("Test2.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;

# code for thumbnail $newimage->copyResized($srcimage,0,0,0,0,$newW,$newH,$srcW,$srcH) ;
 open(FILE, ">index1.jpg") || die "Cannot open index1.jpg: $!\n";
 print FILE $newimage->jpeg(80) ;
 close FILE;
print '<br><br><img src="">';
Who is Participating?
mjcoyneConnect With a Mentor Commented:

 open(FILE, ">index1.jpg") || die "Cannot open index1.jpg: $!\n";
 binmode FILE;
 print FILE $newimage->jpeg(80) ;
 close FILE
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.