Here is the portion in question:
Code: Select all
ob_start();
imagejpeg($image_p, NULL, 100);
$image = ob_get_clean();
ob_end_flush();
return($image);And here is the rest of the code:
Code: Select all
function jpeg_thumbnail($file, $thumb_max_width = 100, $thumb_max_height = 100)
{
if(file_exists($file)){
$details = getimagesize($file);
if($details['mime'] != ('image/jpeg' or 'image/png' or 'image/gif')){
return FALSE;
}
// Get new dimensions
list($width, $height) = $details;
if ($width < $height) {
$thumb_max_width = ($thumb_max_height / $height) * $width;
} else {
$thumb_max_height = ($thumb_max_width / $width) * $height;
}
// Resample
$image_p = imagecreatetruecolor($thumb_max_width, $thumb_max_height);
if($details['mime'] == 'image/jpeg'){
$image = imagecreatefromjpeg($file);
}elseif($details['mime'] == 'image/png'){
$image = imagecreatefrompng($file);
}elseif($details['mime'] == 'image/gif'){
$image = imagecreatefromgif($file);
}
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $thumb_max_width, $thumb_max_height, $width, $height);
// Output
ob_start();
imagejpeg($image_p, NULL, 100);
$image = ob_get_clean();
ob_end_flush();
return($image);
}
}