加入收藏 | 设为首页 | 会员中心 | 我要投稿 柳州站长网 (https://www.0772zz.cn/)- 基础存储、数据迁移、云安全、数据计算、数据湖!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2022-07-28 10:41:48 所属栏目: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);
  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 "文件打开失败,或者指定的不是图像文件";   //输出错误信息
  }//开源代码phpfensi.com

(编辑:柳州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读