in reply to gdImageCreateFromGd2Part

Out of curiosity - being somewhat of a GD newbie myself, can you provide enough of a script to show what you're getting vs what you're expecting? For example, are you saving $newimage to a file and expecting something there, or are you displaying it to a Tk window, or ...?

Thanks!

Replies are listed 'Best First'.
Re^2: gdImageCreateFromGd2Part
by Anonymous Monk on Sep 29, 2005 at 00:51 UTC
    My goal is to select an area from the existing photo and then save it. Right now I'm stuck on the gdImageCreateFromGd2Part function. Here is the actual chunk of code that I'm running. I'm going to have two parts, which execute depending on if the image has more or less than 4 million pixels. If it has less than that number, it uses copyResized. This part works. I'm working on the part that processes images with more than that many pixels. The code works fine apart from the line with the gdImageCreateFromGd2Part function in it. Hope this more detailed code helps:
    my $srcimage = GD::Image->newFromJpeg($target_dir."/".$newName); my ($srcW,$srcH) = $srcimage->getBounds(); if( $srcW*$srcH > 4000000 ){ my $newimage = new GD::Image(100,100); $newimage->gdImageCreateFromGd2Part($srcimage,100,100,100,100); # future code to make a thumbnail from the part that is pulled fro +m the image }else{ my $maxheight = 400; my $maxwidth = 400; 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); } my $newimage = new GD::Image($newW,$newH); $newimage->copyResized($srcimage,0,0,0,0,$newW,$newH,$srcW,$srcH); open(FILE, ">".$target_dir."/preview/".$newName) || die "Cannot op +en image: $!\n"; print FILE $newimage->jpeg; }