获取图片大小
作者:互联网
getimagesize()
一个参数,完成的URL(协议http://,域名www.baidu.com,路由/files/test.jpg),返回的是图片的宽高后缀等
array(7) {
[0]=>
int(640)
[1]=>
int(640)
[2]=>
int(2)
[3]=>
string(24) "width="640" height="640""
["bits"]=>
int(8)
["channels"]=>
int(3)
["mime"]=>
string(10) "image/jpeg"
}
filesize(),参数为文件路径,本地路径可以,线上路径不行,获取的是具体文件的内容大小
如果想获取线上文件的大小可以使用get_headers()
eg:
$b = get_headers('http://imgcdn.tabata.com.hk/files/CNMINISO-20487/2020051643.jpg',true);
var_dump($b);
array(17) {
[0]=>
string(15) "HTTP/1.1 200 OK"
["Date"]=>
string(29) "Wed, 27 Jan 2021 01:25:20 GMT"
["Content-Type"]=>
string(10) "image/jpeg"
["Content-Length"]=>
string(5) "50044"
["Connection"]=>
string(5) "close"
["Set-Cookie"]=>
string(144) "__cfduid=d2d48126a2842af6e5c6bb1240f7d042f1611710720; expires=Fri, 26-Feb-21 01:25:20 GMT; path=/; domain=.tabata.com.hk; HttpOnly; SameSite=Lax"
["Last-Modified"]=>
string(29) "Thu, 31 Dec 2020 18:51:10 GMT"
["ETag"]=>
string(20) ""c37c-5b7c71b6cc9f9""
["Cache-Control"]=>
string(13) "max-age=14400"
["CF-Cache-Status"]=>
string(3) "HIT"
["Age"]=>
string(3) "647"
["Accept-Ranges"]=>
string(5) "bytes"
["cf-request-id"]=>
string(32) "07e30b037b0000d37e5aaad000000001"
["Report-To"]=>
string(237) "{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=orjiStzBq3R6ZELrA%2FCCbD%2Byz5cMl4L1qj5LLWoAmC4i8DpRdWEi32S7sG5%2Bs9MaJ2hcj1SrO4%2BB1iW61d87kgy8%2Fu9xO%2B%2FzRac5i9lmSYi%2FrO1E9Q%3D%3D"}],"group":"cf-nel","max_age":604800}"
["NEL"]=>
string(39) "{"max_age":604800,"report_to":"cf-nel"}"
["Server"]=>
string(10) "cloudflare"
["CF-RAY"]=>
string(20) "617eade45ba1d37e-LAX"
}
$b['Content-Length']就是文件具体大小
标签:10,20,string,640,int,获取,图片大小,com 来源: https://www.cnblogs.com/xiaofeilin/p/14333377.html