Dysan Posted January 4, 2008 Share Posted January 4, 2008 How & is it possible, to resize and crop an image, so it fits perfectly inside a div measuring 72x72 pixels? Quote Link to comment https://forums.phpfreaks.com/topic/84430-resize-crop-image/ Share on other sites More sharing options...
redarrow Posted January 4, 2008 Share Posted January 4, 2008 <?php // The file $filename = 'test.jpg'; // Set a maximum height and width $width = 72; $height = 72; // Content type header('Content-type: image/jpeg'); // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84430-resize-crop-image/#findComment-430069 Share on other sites More sharing options...
Dysan Posted January 4, 2008 Author Share Posted January 4, 2008 How do I crop the image? May I ask you a question? - First of all, do you have PowerPoint/2003? Quote Link to comment https://forums.phpfreaks.com/topic/84430-resize-crop-image/#findComment-430077 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.