PHP Get Image size example, PHP image function Getimageinfo () usage

Source: Internet
Author: User
  1. !--? php function get Imageinfo ($img) {//$img is an absolute path to an image file, for example, D:\iamge\jn0-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. $new _img_info=array (

  17. "width" + $img _info[0],
  18. "height" =>$ IMG_INFO[1],
  19. "type" = = $img _type
  20. "size" + $img _size
  21. }
  22. Return$new_im G_info;
  23. }
  24. ?

copy code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.