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:
- < ?php
- function myimg($imgfile) {
- $size = getimagesize($imgfile);
- echo "
- }
- myimg("img/img1.gif");
- myimg("img/img2.png");
- ?>