Stuff
public text v1 · immutable // Set a maximum height and width
$width = 150;
$height = 150;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($file_destination);
$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($file_destination);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output
imagejpeg($image_p, $thumbnail_image, 100);