PHP Function GetImageSize()
When you pass getimagesize() a filename, it will return an array with the image size and some extra information. The first two elements (index 0 and 1) contain the width and height of the image. Index 2 contains one of the IMAGETYPE_XXX constants indicating what type of image it is, such as IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_SWF, IMAGETYPE_PSD, IMAGETYPE_BMP, IMAGETYPE_TIFF_II or IMAGETYPE_TIFF_MM, IMAGETYPE_JPX, IMAGETYPE_JP2, IMAGETYPE_ICO or IMAGETYPE_SWC. The last value (index 3) is a text string with the correct height="yyy" and width="xxx" string that can be used directly in an IMG tag.
If the file type is unknown, or if there is no image inside of it, this function will return a false value for the image size. In some rare cases, this function may also return a warning for not being able to access the stream.
This function uses the GD library to retrieve image information. If you are using PHP older than 5.3, it may not work with certain types of files. For example, if you try to use this function with an ICO file, you will receive a false value because support for this format was only added in PHP version 7.1. You can work around this by passing in the fileinfo extension instead of this function. You can also get extended image information from this function, such as the different JPEG APP markers as an associative array. See the documentation for more details.