1; } /** * Get image information * * @param string $filename * @return array|false */ public static function getImageInfo($filename) { if (!self::isImage($filename)) { return false; } if (!$image_info = @getimagesize($filename)) { return false; } $img_type = [ IMG_GIF => 'gif', IMG_JPG => 'jpg', // jpeg is the same as jpg IMG_PNG => 'png', IMG_WEBP => 'webp', IMG_WBMP => 'wbmp', IMG_XPM => 'xpm', (defined('IMG_BMP') ? IMG_BMP : 64) => 'bmp', ]; return [ 'width' => $image_info[0], 'height' => $image_info[1], 'type' => $img_type[$image_info[2]], 'bits' => $image_info['bits'] ?? null, 'channels' => $image_info['channels'] ?? null, ]; } }