techtheatre Posted April 11, 2007 Share Posted April 11, 2007 I am trying to resize some images that i upload to my webserver. I found a great (well it looks great...i have not yet used it) script to do this with GD, but i can't see where to rename the output file. This tutorial was found here: http://www.phptoys.com/e107_plugins/content/content.php?content.46 <?php function resizeImage($originalImage,$toWidth,$toHeight){ // Get the original geometry and calculate scales list($width, $height) = getimagesize($originalImage); $xscale=$width/$toWidth; $yscale=$height/$toHeight; // Recalculate new size with default ratio if ($yscale>$xscale){ $new_width = round($width * (1/$yscale)); $new_height = round($height * (1/$yscale)); } else { $new_width = round($width * (1/$xscale)); $new_height = round($height * (1/$xscale)); } // Resize the original image $imageResized = imagecreatetruecolor($new_width, $new_height); $imageTmp = imagecreatefromjpeg ($originalImage); imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height); return $imageResized; } ?> basically i just need a function that will resize and keep the proper porportions. my original image is named 1_fullsize.jpg and i want to create one called 1_thumb.jpg (and another called 1_normal.jpg). Where do i go about putting the new filename/path into this script to save my file? Also, i have been told that ImageMagick is really the way to go...but have not been able to find easy tutorials for it...any thoughts on where i can find an easy imagemagick function to handle this (i have searched google for ImageMagick resize tutorial which is actually how i found this one using GD :-\ ) Thanks! Quote Link to comment Share on other sites More sharing options...
Glyde Posted April 11, 2007 Share Posted April 11, 2007 Try: imagejpeg(resizeImage($sourceImage, $toWidth, $toHeight), "filename.jpg"); Should work. Quote Link to comment Share on other sites More sharing options...
techtheatre Posted April 11, 2007 Author Share Posted April 11, 2007 great! Thanks! I will give this a shot... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.