getimagesizefromstring

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

getimagesizefromstring从字符串中获取图像尺寸信息

说明

getimagesizefromstring(string $string, array &$image_info = null): array|false

getimagesize() 函数,区别是 getimagesizefromstring() 的第一个参数是接受字符串而不是文件名。

关于本函数如何工作的更多信息请参见 getimagesize() 函数。

参数

string

图像数据的字符串表示。

image_info

参见 getimagesize()

返回值

参见 getimagesize()

范例

示例 #1 getimagesizefromstring() 示例

<?php
$img
= '/path/to/test.png';

// 以文件方式打开
$size_info1 = getimagesize($img);

// 以字符串格式打开
$data = file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
?>

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top