從字串中獲取影象尺寸資訊

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);
?>

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *