getimagesizefromstring
(PHP 5 >= 5.4.0, PHP 7, PHP 8)
getimagesizefromstring — 從字串中獲取影象尺寸資訊
說明
getimagesizefromstring(string
$imagedata
, array &$imageinfo
= ?): array同 getimagesize() 函式。 區別是 getimagesizefromstring() 第一個參數是影象數據的字串表達,而不是檔名。
關於本函式如何工作的更多資訊請參見 getimagesize() 函式。
參數
-
imagedata
-
影象數據的字串表示。
-
imageinfo
-
參見 getimagesize() 函式。
返回值
參見 getimagesize() 函式。
範例
示例 #1 getimagesizefromstring() 函式例程
<?php
$img = '/path/to/test.png';
// 以檔案方式打開
$size_info1 = getimagesize($img);
// 以字串格式打開
$data = file_get_contents($img);
$size_info2 = getimagesizefromstring($data);
?>