Php getting image size (width, height) _ PHP Tutorial

Source: Internet
Author: User
Php obtains the image size (width and height ). This article mainly describes the function of PHP to obtain the image size (width, height), that is, the getimagesize () function. Syntax: arraygetimagesize (stringfilename [, arrayimageinfo]) function: This article mainly describes the function of PHP to obtain the image size (width, height), that is, the getimagesize () function.

Syntax: array getimagesize (string filename [, array & imageinfo])

Function: The getimagesize () function will determine any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, the size, size, file type, and a height/width text string that can be used in a common HTML file. If the specified image cannot be accessed or is not valid, getimagesize () returns FALSE and generates an E_WARNING error.

Note:

(1) This function is not supported by the GD Image Library.

(2) in addition to obtaining information about local images or Flash, this function can also be used directly to obtain remote information.

Example:

 ";echo "Image height ".$height;echo "
";echo "Image type ".$type;echo "
";echo "Attribute ".$attr;

The output information is as follows:

Image width 200
 
Image height 55
 
Image type 1
 
Image attribute width = "200" height = "55"

The parameters of the image type are as follows:
 
1 = GIF 5 = PSD 9 = JPC 13 = SWC
 
2 = JPG 6 = BMP 10 = JP2 14 = IFF
 
3 = PNG 7 = TIFF (intel byte order) 11 = JPX 15 = WBMP
 
4 = SWF 8 = TIFF (motorola byte order) 12 = JB2 16 = XBM

Articles you may be interested in
  • Php obtains the screen width, height, and resolution of the client computer.
  • Javascript is a method for obtaining the width and height of an image.
  • Js address bar special effects (display the size of all images with links on the page and view the height of the current browser)
  • Powerful PHP image processing class (Watermark, transparency, zoom, sharpen, rotate, flip, cut, reversed)
  • Php retrieves remote images and downloads and saves them to a local device.
  • Text area textarea box adaptive height based on input content
  • How does PHP enable compression and output for websites to increase website access speed?
  • Js checks whether the image is loaded and obtains the image width.

The (width, height) function, that is, the getimagesize () function. Syntax: array getimagesize (string filename [, array imageinfo]) function :...

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.