Home > php教程 > php手册 > 用php或js获取图片大小,高宽尺寸.

用php或js获取图片大小,高宽尺寸.

WBOY
Release: 2016-06-13 10:31:57
Original
984 people have browsed it


$arr=getimagesize("images/album_01.gif");
echo $arr[3];
$strarr=explode(""",$arr[3]);
echo $strarr[1];
?>



演示图片等比例缩小
<script> <BR>function Wa_SetImgAutoSize(img) <BR>&#123; <BR>//var img=document.all.img1;//获取图片 <BR>var MaxWidth=200;//设置图片宽度界限 <BR>var MaxHeight=100;//设置图片高度界限 <BR>var HeightWidth=img.offsetHeight/img.offsetWidth;//设置高宽比 <BR>var WidthHeight=img.offsetWidth/img.offsetHeight;//设置宽高比 <BR>alert("test"+img.offsetHeight+img.fileSize);<BR>if(img.offsetHeight>1) alert(img.offsetHeight);<BR>if(img.readyState!="complete")&#123;<BR> return false;//确保图片完全加载<BR>&#125;<P>if(img.offsetWidth>MaxWidth)&#123; <BR>img.width=MaxWidth; <BR>img.height=MaxWidth*HeightWidth; <BR>&#125; <BR>if(img.offsetHeight>MaxHeight)&#123; <BR>img.height=MaxHeight; <BR>img.width=MaxHeight*WidthHeight; <BR>&#125; <BR>&#125; <P>function CheckImg(img) <BR>&#123; <BR> var message="";<BR> var MaxWidth=1;//设置图片宽度界限 <BR> var MaxHeight=1;//设置图片高度界限 <BR> <BR> if(img.readyState!="complete")&#123;<BR> return false;//确保图片完全加载<BR> &#125;<BR> if(img.offsetHeight>MaxHeight) message+="高度超额:"+img.offsetHeight;<BR> if(img.offsetWidth>MaxWidth) message+="宽度超额:"+img.offsetWidth;<BR> if(message!="") alert(message);<BR>&#125; <BR></script>


用php或js获取图片大小,高宽尺寸.




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template