php getimagesize function - Get image information
The getimagesize() function is used to obtain the image size and related information. It returns an array if successful. If it fails, it returns FALSE and generates an E_WARNING level error message.
Syntax format:
array getimagesize ( string $filename [, array &$imageinfo ] )
getimagesize() function will measure any GIF, JPG, PNG, SWF, SWC, PSD, TIFF, BMP, IFF, JP2, JPX, JB2, JPC, XBM Or the size of a WBMP image file and returns the dimensions of the image as well as the file type and image height and width.
Example 1: Local image file
<?php list($width, $height, $type, $attr) = getimagesize("runoob-logo.png"); echo "宽度为:" . $width; echo "高度为:" . $height; echo "类型为:" . $attr; ?>
The output result of the above example is:
宽度为:290 高度为:69 类型为:3 属性:width="290" height="69"
Example 2: Remote image file
<?php $remote_png_url = ' $img_data = getimagesize($remote_png_url);print_r($img_data );?>
The output result of the above example is: :
Array( [0] => 290 [1] => 69 [2] => 3 [3] => width="290" height="69" [bits] => 8 [mime] => image/png)
Return result description
Index 0 gives the pixel value of the image width
Index 1 gives the pixel value of the image height
Index 2 gives the type of image and returns a number, where 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF (intel byte order), 8 = TIFF (motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
Index 3 is given is a string of width and height, which can be directly used in the
The index bits gives the number of bits for each color of the image, in binary format
Index channels gives the channel value of the image. The default for RGB images is 3
. Index mime gives the MIME information of the image. This information can be used to send the correct information in the HTTP Content-type header. , such as: header("Content-type: image/jpeg");
The above is the php getimagesize function - the content of obtaining image information. For more related content, please pay attention to the PHP Chinese website (www.php.cn) !

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics









