【发布时间】:2012-03-31 05:19:08
【问题描述】:
我有一个功能可以即时制作网址图像的缩略图! 我总是将 jpg 类型的图像传递给此函数,但是当我传递带有“.jpg”扩展名的图像时会出现问题。但是当我尝试获取它的 mime 类型时,我发现它是“application/octet-stream”.. 在这个 php page 中,这个 mime 类型指的是一种
IMAGETYPE_JPC,IMAGETYPE_JPX,IMAGETYPE_JB2
我需要修改我的函数来处理这种 mime 类型吗??
通知^^^^^^
function thumb($path,$width,$height) // $path => image url
{
$file_dimensions = getimagesize($path);
$file_type = image_type_to_mime_type($file_dimensions[2]);
list($Cwidth, $Cheight) = getimagesize($path);
if ($file_type=='image/jpeg'||$file_type=='image/pjpeg'){
// Load
$thumb = imagecreatetruecolor($width, $height);
$source = imagecreatefromjpeg($path);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $Cwidth, $Cheight);
header('Content-Type: image/jpeg');
imagejpeg($thumb);
}
else if ($file_type=='application/octet-stream')
{
// ^^^^^ what I should write here
}
else
{
echo "Not supported type";
}
}
【问题讨论】:
标签: php thumbnails mime-types gd2