Redlightpacket Posted October 8, 2009 Share Posted October 8, 2009 I need this script to be basic so I can understand it. Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/176991-need-a-simple-php-image-resize-script/ Share on other sites More sharing options...
jamesxg1 Posted October 8, 2009 Share Posted October 8, 2009 Google this i found a very lot of really easy tutorials for this. James. Link to comment https://forums.phpfreaks.com/topic/176991-need-a-simple-php-image-resize-script/#findComment-933171 Share on other sites More sharing options...
lemmin Posted October 8, 2009 Share Posted October 8, 2009 I don't think you are supposed to make requests here, but I happen to have a pretty simple script already. This will resize the image to the max width or height specified, maintaining the ratio: $size = getimagesize($filename); $img = imagecreatefromjpeg($filename); $maxWidth = 300; $maxHeight = 300; if ($size[0] > $size[1] && $size[0] > 300) { $newHeight = $size[1]/($size[0]/$maxWidth); $newWidth = $maxWidth; } else if ($size[1] > $size[0] && $size[1] > 300) { $newHeight = $maxHeight; $newWidth = $size[0]/($size[1]/$maxHeight); } else { $newHeight = $size[1]; $newWidth = $size[0]; } $tn = imagecreatetruecolor($newWidth, $newHeight); imagecopyresized($tn, $img, 0, 0, 0, 0, $newWidth, $newHeight, $size[0], $size[1]); Link to comment https://forums.phpfreaks.com/topic/176991-need-a-simple-php-image-resize-script/#findComment-933173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.