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 :...