1. image_type=image_type_to_mime_type(imagetype_png);   //獲取png的mime類型 
  2. echo $image_type;           //輸出結(jié)果 
  3.  
  4. // 
  5.  
  6.  
  7. $file = '1.jpg'
  8. $image = imagecreatefromjpeg($file); 
  9. header('content-type: ' . image_type_to_mime_type(imagetype_wbmp)); 
  10. $fp=fopen($file,r); 
  11. fpassthru($fp); 
  12. image2wbmp($image,"1.bmp"); // output the stream directly 
  13.  
  14. //image_type_to_extension. (php教程 5). image_type_to_extension — 取得圖像類型的文件 后綴 ... warning. 本函數(shù)暫無(wú)文檔 
  15.  
  16. $file_ext=image_type_to_extension("1.jpg"); 
  17. echo $file_ext
  18.  
  19. // 
  20.  
  21. $filename="1.jpg";         //定義圖像文件 
  22. $size=getimagesize($filename);      //獲取圖像的大小 
  23. $fp=fopen($filename,"rb");        //打開文件 
  24. if($size && $fp)          //如果成功打開 
  25.   header("content-type: {$size['mime']}");     //輸出文件頭信息 
  26.   fpassthru($fp);         //輸出文件內(nèi)容 
  27.   exit;           //中止操作 
  28. else 
  29.   echo "文件打開失敗,或者指定的不是圖像文件";   //輸出錯(cuò)誤信息 
  30. }//開源代碼phpfensi.com
轉(zhuǎn)載請(qǐng)注明來(lái)源:php 圖片處理函數(shù) 獲取類型 擴(kuò)展名

  哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無(wú)需額外費(fèi)用,即可穩(wěn)步提升排名至首頁(yè)。歡迎體驗(yàn)最佳的哈爾濱網(wǎng)站建設(shè)。