Home > Backend Development > PHP Tutorial > Example of php getting image size, usage of php image function getImageInfo()

Example of php getting image size, usage of php image function getImageInfo()

WBOY
Release: 2016-07-25 08:51:28
Original
883 people have browsed it
  1. function getImageInfo($img){ //$img is the absolute path of the image file, for example, D:iamgejn0-541.gif

  2. $img_info=getimagesize($img );
  3. switch($img_info[2]){
  4. case1:
  5. $imgtype="GIF";
  6. break;
  7. case2:
  8. $imgtype="JPG";
  9. break;
  10. case3:
  11. $imgtype="PNG" ;
  12. break;
  13. }
  14. $img_type=$imgtype."image";
  15. $img_size=ceil(filesize($img)/1000)."k"; //Get file size

  16. "width"=>$img_info[0],
  17. "height"=>$img_info[1],
  18. "type"=>$img_type
  19. "size"=>$img_size
  20. }
  21. return$new_img_info;
  22. }
  23. ?>

Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template