CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: four minus one?
(Example: nine)

The Note You're Voting On

John Luetke <johnl1479 gmail com>
19 years ago
Rewrote the manual example into this function for creating a thumbnail image:

function thumbnail_jpeg ($original, $thumbnail, $width, $height, $quality) {
list($width_orig, $height_orig) = getimagesize($original);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
}
else {
$height = ($width / $width_orig) * $height_orig;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($originial);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
imagejpeg($image_p, $thumbnail, $quality);
return;
}

<< Back to user notes page

To Top