array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.getimagesizefromstring.php', 1 => 'getimagesizefromstring', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'GD 和图像处理 函数', ), 'prev' => array ( 0 => 'function.getimagesize.php', 1 => 'getimagesize', ), 'next' => array ( 0 => 'function.image-type-to-extension.php', 1 => 'image_type_to_extension', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/image/functions/getimagesizefromstring.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.4.0, PHP 7, PHP 8)
getimagesizefromstring — 从字符串中获取图像尺寸信息
同 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);
?>