1 回答

TA貢獻1816條經驗 獲得超6個贊
我相信你可以使用,
getimagesize()
https://www.php.net/manual/en/function.getimagesize.php
它將返回您正在尋找的屬性數組。包括高度和寬度。它要求在您的服務器配置中將 allow_url_fopen 設置為 true。假設圖像是遠程的。
所以在你的情況下。它可能看起來像……
$files = [];
// maybe pass this by reference as &$image and store the totals in the same array, otherwise
foreach ($images as $image) {
$attributes = getimagesize($image);
$height = $attributes[0];
$width = $attributes[1];
$total = $height + $width;
// bind the total as the id of the array, if there are multiple matching totals, it will always be the last
// image that matches that is selected.
$files[$total] = $image;
}
// then you can use any standard logic to extract the data from the new array.
- 1 回答
- 0 關注
- 136 瀏覽
添加回答
舉報