PHP getimagesizefromstring - 獲取圖片資訊函數
getimagesizefromstring — 從字串中獲取圖像尺寸資訊。
語法
array getimagesizefromstring ( string $imagedata [, array &$imageinfo ] )
同 getimagesize() 函數。 區別是 getimagesizefromstring() 第一個參數是圖像數據的字串表達,而不是檔案名。
參數
- imagedata: 圖像數據的字串表示。
- imageinfo: 參見 getimagesize() 函數。
實例
<?php $img = 'zaixian-logo.png'; // 以檔方式打開 $size_info1 = getimagesize($img); // 以字串格式打開 $data = file_get_contents($img); $size_info2 = getimagesizefromstring($data); print_r($size_info2); ?>
以上實例輸出結果為:
Array
(
[0] => 290
[1] => 69
[2] => 3
[3] => width="290" height="69"
[bits] => 8
[mime] => image/png
)

PHP 圖像處理