What is the usage of the PHP getimagesize function?

The getimagesize() function is used to obtain the dimensions and file type of an image. It takes the path of the image file as a parameter and returns an array containing the width, height, type, and MIME type of the image.

Here is a basic example:

$filename = 'path/to/your/image.jpg';
$imagesize = getimagesize($filename);

echo 'Image width: ' . $imagesize[0] . 'px<br>';
echo 'Image height: ' . $imagesize[1] . 'px<br>';
echo 'Image type: ' . $imagesize[2] . '<br>';
echo 'MIME type: ' . $imagesize['mime'];

注意:The getimagesize() function can only be used to read local files and cannot be used to read remote files.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds