PHP obtains the image width, height, size, size, and image type.

Source: Internet
Author: User
Phpself-contained getimagesize()$img_infogetimagesize('test.jpg '); echo' & lt; pre & gt; '; print_r ($ img_info); echo' & lt;/pre & gt; '; output: Array; (& nbsp ;[

Php built-in function getimagesize ()

$ Img_info = getimagesize('test.jpg '); echo'
'; Print_r ($ img_info); echo'
';

Output:

Array? (??[0] => 170?[1] => 254?[2] => 2?[3] = & gt; width = "170" height = "254 "?[Bits] => 8?[Channels] => 3?[Mime] => image/jpeg)

The first index value indicates the width, the second index value indicates the height, and the third index value indicates the image type (1 is gif, 2 is jpg/jpeg, 3 is png, and so on, the value of channels is 3 for RGB images, 4 for CMYK images, bits is the digits of each color, and mime represents the MIME type of the image.

Note: This function does not require the GD Image Library.

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.