note 43288 deleted from function.imagecopyresampled by aidan

From: Date: Mon, 04 Oct 2004 09:42:38 +0000
Subject: note 43288 deleted from function.imagecopyresampled by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77939@lists.php.net to get a copy of this message
Note Submitter: ---- here is my clear method to resize images you can check how it works on http://www.jetevents.pl/index.php <?php $maxx=100; // maximum width $maxy=75; // maximum height $name=strtolower(substr($_FILES['file']['name'],0,-4)).".jpg"; // name of file - must be jpg $size = GetImageSize ($_FILES['file']['tmp_name']); // params of image if ($size[0]>$size[1]) {$sizemin[0]=$maxx;$sizemin[1]=$maxy;}; if ($size[1]>$size[0]) {$sizemin[0]=$maxy;$sizemin[1]=$maxx;}; $im=@imagecreatefromjpeg($path); // path to your gallery $small = imagecreatetruecolor($sizemin[0], $sizemin[1]); // new image ImageCopyResampled($small, $im, 0, 0, 0, 0, $sizemin[0], $sizemin[1], $size[0], $size[1]); // below is main function resampling image ImageDestroy($im); // free memory if (ImageJPEG($small,$path,100)) // try to save image { echo "File $path has been written<br>\n"; // success echo "size: ".$sizemin[0]."x".$sizemin[1] ."<br>\n"; } else { echo "<font color=red><b>"; // failed to write file echo "Error ! File has not been written."; echo "</b></font><br>\n"; }; ?>

« previous php.notes (#77939) next »