我有一个功能,可以在飞行中制作网址图片缩略图!
我总是传递给jpg类型的这个函数图像,但是当我传递带有“.jpg”扩展名的图像时会出现问题.但当我尝试获取其mime类型时,我发现这是“应用程序/八位字节流”..在这个
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";
}
}