PHP obtains image information

Source: Internet
Author: User
PHP retrieves image information $ img is the absolute path of the image file

 

PHP code
  1. Function getimageinfo ($ img) {// $ img is the absolute path of the image file.
  2. $ Img_info = getimagesize ($ img );
  3. Switch ($ img_info [2]) {
  4. Case 1:
  5. $ Imgtype = gif;
  6. Break;
  7. Case 2:
  8. $ Imgtype = jpg;
  9. Break;
  10. Case 3:
  11. $ Imgtype = png;
  12. Break;
  13. }
  14. $ Img_type = $ imgtype. image;
  15. $ Img_size = ceil (filesize ($ img)/1000). k; // get the 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_img_info;
  23. }

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.