PHP下一个非常全面获取图象信息的函数
(编辑:jimmy 日期: 2024/11/17 浏览:3 次 )
复制代码 代码如下:
<?php
function getimageinfo(img) { //img为图象文件绝对路径
img_info = getimagesize(img);
switch (img_info[2]) {
case 1:
imgtype = "gif";
break;
case 2:
imgtype = "jpg";
break;
case 3:
imgtype = "png";
break;
}
img_type = imgtype."图像";
img_size = ceil(filesize(img)/1000)."k"; //获取文件大小
new_img_info = array (
"width"=>img_info[0],
"height"=>img_info[1],
"type"=>img_type
"size"=>img_size
}
return new_img_info;
}
?>
<?php
function getimageinfo(img) { //img为图象文件绝对路径
img_info = getimagesize(img);
switch (img_info[2]) {
case 1:
imgtype = "gif";
break;
case 2:
imgtype = "jpg";
break;
case 3:
imgtype = "png";
break;
}
img_type = imgtype."图像";
img_size = ceil(filesize(img)/1000)."k"; //获取文件大小
new_img_info = array (
"width"=>img_info[0],
"height"=>img_info[1],
"type"=>img_type
"size"=>img_size
}
return new_img_info;
}
?>
下一篇:PHP脚本中include文件出错解决方法