This article mainly describes the PHP to get picture size (width, height) function, 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,XBM or wbmp image file and return the file size, size, The file type and a height/width text string that can be used in the tag in a normal HTML file. If the specified image cannot be accessed or is not a valid image, GetImageSize () returns false and generates a e_warning level error.
Note:
(1) This function does not need the GD Image Library support.
(2) The function can be used to obtain remote data in addition to the local picture or flash information.
Example:
<?php
list ($width, $height, $type, $attr) =getimagesize ("logo.gif");
echo "Image width". $width;
echo "<br/>";
echo "Image height". $height;
echo "<br/>";
echo "Image type". $type;
echo "<br/>";
echo "Attribute". $attr;
The output information is as follows:
Image width 200
Image Height 55
Image Type 1
Image attribute width= "height=" "55"
The parameters of the picture type are referenced as follows:
1 = GIF 5 = PSD 9 = JPC = SWC
2 = JPG 6 = BMP = JP2 = IFF
3 = PNG 7 = TIFF (Intel byte order) one = JPX = WBMP
4 = SWF 8 = TIFF (motorola byte order) = JB2 = XBM
Articles that you may be interested in
- PHP access to the client computer screen width, height, resolution method
- JS Address bar effects (display the size of all the linked pictures on the page and view the height of the current browser)
- A way for JavaScript to get the width and height of a picture
- Powerful PHP Image processing class (watermark, transparency, zoom, sharpen, rotate, flip, cut, invert color)
- PHP Gets the remote picture and downloads it to the local
- How PHP determines whether a GIF picture is a dynamic picture (animation)
- Text area textarea box adapts height to input
- Use PHP function memory_get_usage to get current PHP memory consumption to achieve program performance optimization