php擷取圖片詳細資料(寬 高 格式 大小)

來源:互聯網
上載者:User
  1. function getImageInfo($img) //$img為影像檔絕對路徑
  2. {
  3. $img_info = getimagesize($img);
  4. switch ($img_info[2]) {
  5. case 1:
  6. $imgtype = "GIF";
  7. break;
  8. case 2:
  9. $imgtype = "JPG";
  10. break;
  11. case 3:
  12. $imgtype = "PNG";
  13. break;
  14. }
  15. $img_type = $imgtype . "映像";
  16. $img_size = ceil(filesize($img) / 1000) . "k"; //擷取檔案大小
  17. $new_img_info = array(
  18. "width" => $img_info[0],
  19. "height" => $img_info[1],
  20. "type" => $img_type,
  21. "size" => $img_size
  22. );
  23. print " width";
  24. print $img_info[0];
  25. print " height";
  26. print $img_info[1];
  27. print " format";
  28. print $img_type;
  29. print " size";
  30. print $img_size;
  31. print $new_img_info;
  32. }
  33. $img = "/www/htdocs/images/jf.gif";
  34. getImageInfo($img);
  35. ?>
複製代碼
php
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.