Code: Select all
//Thumbnail size
$dest_x = 178;
$dest_y = 55;
//Image reduction
$iratio = 3.23;
$widthratio = $width_orig / $iratio;
$heightratio = $height_orig / $iratio;
if ($width_orig >= $height_orig) {
$width_new = $width_orig;
$height_new = $heightratio;
} else {
$width_new = $width_orig;
$height_new = $widthratio;
}
//Generate a new image at the size of the thumbnail
$thumb = imagecreatetruecolor($dest_x,$dest_y);
//Copy the original image data to it using resampling
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $dest_x, $dest_y, $width_new, $height_new);
//Save the thumbnail
imagejpeg($thumb, "images/work/$type/thumb_$filename", 80);
}