Name
getimagesize
Synopsis
array getimagesize(stringpath
[, array &info
])
Returns an array with five elements by checking the size of the image found at path. Path can either be absolute path to a file on the filesystem, or a URI pointing to a file. The following elements are returned in the array:
| The width of the image in pixels |
| The height of the image in pixels |
| The type of the image according to the values in the next table |
| The height and width as a string that can be used inside an IMG element directly (for example, height="123” width="16”) |
| The MIME type for the image |
| If it can be determined, the number of channels in the image (for example, 3 for RGB images or 4 for CMYK images) |
| If it can be determined, the number of bits used for each pixel in the image |
The image types supported and the type value and MIME type returned for each image type are as follows:
| Graphics Interchange Format (GIF) |
| JPEG |
| Portable Network Graphics format (PNG) |
| Shockwave or Flash animation (SWF) |
| PhotoShop file (PSD) |
| Windows bitmap format (BMP) |
| TIFF (Intel byte-ordered) |
| TIFF (Motorola byte-ordered) |
| JPC |
| JP2 |
| JPX |
| JB2 |
| SWC |
| IFF |
| WBMP |
| XBM |
If supplied, the array info
is
filled with additional information parsed from the file, depending
on the file type. For example, JPEG files may contain IPTC data in
JPG APP markers. In cases where they exist, marker keys and values
are returned in info.
Get Programming PHP, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.