php改变图片类型,php 图片处理函数 获取类型 扩展名

image_type=image_type_to_mime_type(imagetype_png);   //获取png的mime类型

echo $image_type;           //输出结果

//

$file = '1.jpg';

$image = imagecreatefromjpeg($file);

header('content-type: ' . image_type_to_mime_type(imagetype_wbmp));

$fp=fopen($file,r);

fpassthru($fp);

image2wbmp($image,"1.bmp"); // output the stream directly

//image_type_to_extension. (php教程 5). image_type_to_extension — 取得图像类型的文件 后缀 ... warning. 本函数暂无文档

$file_ext=image_type_to_extension("1.jpg");

echo $file_ext;

//

$filename="1.jpg";         //定义图像文件

$size=getimagesize($filename);      //获取图像的大小

$fp=fopen($filename,"rb");        //打开文件

if($size && $fp)          //如果成功打开

{

header("content-type: {$size['mime']}");     //输出文件头信息

fpassthru($fp);         //输出文件内容

exit;           //中止操作

}

else

{

echo "文件打开失败,或者指定的不是图像文件";   //输出错误信息

}

收藏随意^^请保留教程地址.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值