A function for fully retrieving image information

Source: Internet
Author: User
& Lt ;? Php & nbsp; function & nbsp; getImageInfo ($ img) & nbsp; {& nbsp; // $ img indicates the absolute path of an image file & nbsp; $ img_info & nbsp; getimagesize ($ img); & nbsp; switch & nbsp; ($ img_info [2]) & nbsp ;{&
Function getImageInfo ($ img) {// $ img is the absolute path of the image file.
$ Img_info = getimagesize ($ img );
Switch ($ img_info [2]) {
Case 1:
$ Imgtype = "GIF ";
Break;
Case 2:
$ Imgtype = "JPG ";
Break;
Case 3:
$ Imgtype = "PNG ";
Break;
}
$ Img_type = $ imgtype. "image ";
$ Img_size = ceil (filesize ($ img)/1000). "k"; // get the file size

$ New_img_info = array (
"Width" => $ img_info [0],
"Height" => $ img_info [1],
"Type" => $ img_type
"Size" => $ img_size
}
Return $ new_img_info;
}
?>
It's very simple. you should understand it.

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.