PHP Get Picture Details (width and height format size)

Source: Internet
Author: User
  1. function Getimageinfo ($img)//$img absolute path for image file
  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. "Image";
  16. $img _size = ceil (filesize ($img)/1000). "K"; Get File size
  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. ?>
Copy Code
Php
  • 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.