2690

In PHP’s getimagesize function, the resource ID of WebP is 18

I’d like to use the getimagesize function to handle a WebP situation, but it seems that the resource It seems that the ID is set, and it took me a long time to check it, so I made a note of it The following table shows you how to use the

The version of PHP is important.

To be able to handle WebP, you must have PHP 7.1 or later.

In getimagesize, the number [2]

In getimagesize, the number [2] is assigned to each image format.

 <?php
// Retrieve information about the image.
$imgdata = getimagesize('path-to-img.webp');

print_r($imgdata);
/
Array
(
[0] => 400 // width(px)
[1] => 300 // height(px)
[2] => 18 // The number here
[3] => width="400" height="300" // Attributes and values of img tags
[bits] => 8 // Bit depth
[channels] => 3 // Number of channels
[mime] => image/webp // MIME type.
)
/

IMAGETYPE constant

IMAGETYPE constant number is assigned.
The numbers are as follows.

number format
1 GIF
2 JPEG
3 PNG
4 SWF
5 PSD
6 BMP
7 TIFF_II (intel byte order)
8 TIFF_MM (motorola byte order)
9 JPC
10 JP2
11 JPX
12 JB2
13 SWC
14 IFF
15 WBMP
16 XBM
17 ICO
18 WEBP

reference

[itemlink post_id=”1975″]

Exit mobile version