waq2062 Posted December 7, 2008 Share Posted December 7, 2008 Hi All, I am uploading an image file using move_uploaded_file function. and once the image has been uploaded i want to give user an option to change its height and width so that user could change size of the image and then save it again. Is it possible, can anyone help me out how can i do it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/135857-solved-resizing-a-saved-image-using-php/ Share on other sites More sharing options...
MadTechie Posted December 7, 2008 Share Posted December 7, 2008 Heres a basic jpeg resize script.. you should be able to tweak this to suite your needs <?php // File and new size $filename = 'test.jpg'; $percent = 0.5; // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb, $filename); ?> Quote Link to comment https://forums.phpfreaks.com/topic/135857-solved-resizing-a-saved-image-using-php/#findComment-708191 Share on other sites More sharing options...
waq2062 Posted December 10, 2008 Author Share Posted December 10, 2008 Thanks a lot for the code. Quote Link to comment https://forums.phpfreaks.com/topic/135857-solved-resizing-a-saved-image-using-php/#findComment-711418 Share on other sites More sharing options...
sniperscope Posted January 7, 2009 Share Posted January 7, 2009 Heres a basic jpeg resize script.. you should be able to tweak this to suite your needs <?php // File and new size $filename = 'test.jpg'; $percent = 0.5; // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb, $filename); ?> Could someone explain me how can i integrate this script into my app. ? I want resizing image jpg file when output only. Size of image remain original but want to make it small when picture requested. Regards Quote Link to comment https://forums.phpfreaks.com/topic/135857-solved-resizing-a-saved-image-using-php/#findComment-731481 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.