我不需要调整此图像的大小,我所要完成的所有工作就是收集$ img的实际高度,就像浏览器解释它一样。我允许用户上传任何图像出于某种原因某些图像不会返回维度,只是这个getImageSize();获取图像的高度,无论是什么MIME类型
$img = $_GET['img'];
unction remoteImage($url){
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_RANGE, "0-10240");
$fn = $img;
$raw = curl_exec($ch);
$result = array();
if(file_exists($fn)){
unlink($fn);
}
if ($raw !== false) {
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status == 200 || $status == 206) {
$result["w"] = 0;
$result["h"] = 0;
$fp = fopen($fn, 'x');
fwrite($fp, $raw);
fclose($fp);
$size = getImageSize($fn);
if ($size===false) {
// Cannot get file size information
} else {
// Return width and height
list($result["w"], $result["h"]) = $size;
}
}
}
curl_close ($ch);
return $result;
}
$outputheight = $result["h"];
当我尝试使用getImageSize()时,返回空白。 – Nato 2014-12-06 05:33:13
方法不是getImageSize()它是getimagesize() – 2014-12-06 05:34:36
我一直在阅读这个和基于图像的创建方式,图像可能埋葬在代码中的实际高度和宽度取决于使用什么样的图像创建最终的副本。我不知道这是否属实。我想知道是否有一种方法来预加载图像并使用DOM提取它? – Nato 2014-12-06 05:37:12