功能
getimagesize()
需要文件名,而不是图像资源。它会发出警告,这就是图像无效的原因,因为在图像二进制之前有一个字符串。
$photos = glob($_GET['a'] . '/*.*');
$filename = $photos[array_rand($photos)] ;
$img = imagecreatefromjpeg($filename);
list($width, $height) = getimagesize($filename);
或使用
imagesx()
和
imagesy()
要获取图像大小,请使用
$img
.
$photos = glob($_GET['a'] . '/*.*');
$img = imagecreatefromjpeg($photos[array_rand($photos)]);
$width = imagesx($img);
$height = imagesy($img);