How to Use the PHP function getimagesize

Source: Internet
Author: User

Definition

Obtain the length and width of the image.

Syntax:

Array getimagesize (string filename, array [imageinfo]);

Return Value:

Array

Function types:

Graphic Processing

Description:

The PHP function getimagesize can be used to obtain the height and width of gif, jpeg, and png www slices. You can use this function without installing the gd library. The returned array has four elements. The first element of the returned array (index value 0) is the image height, measured in pixels ).

The second element (index value 1) is the image width. The third element (index value 2) is the image file format. The value 1 is gif, 2 is jpeg/jpg, and 3 is png. The fourth element (index value 3) is the image's high and wide string, height = xxx width = yyy.

The parameter imageinfo that can be omitted is used to obtain information about some images, such as the app13 tag of iptc (http://www.xe.net/iptc), which can be added to the image and parsed using iptcparse.

Sample Code for the PHP function getimagesize:

 
 
  1. < ?php  
  2. function myimg($imgfile) {  
  3. $size = getimagesize($imgfile);  
  4. echo "
  5. }  
  6. myimg("img/img1.gif");  
  7. myimg("img/img2.png");  
  8. ?> 


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.