php 图像mime,php – 如何处理图像的mime类型“application / octet-stream”?

我有一个功能,可以在飞行中制作网址图片缩略图!

我总是传递给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";

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值