Home > Backend Development > PHP Tutorial > Use PHP or JS to get image size, height and width_PHP tutorial

Use PHP or JS to get image size, height and width_PHP tutorial

WBOY
Release: 2016-07-13 10:58:55
Original
846 people have browsed it

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



Demo picture scaled down
<script><br> function Wa_SetImgAutoSize(img)<br> {<br> //var img=document.all.img1;//Get the picture<br> var MaxWidth=200;//Set the image width limit<br> var MaxHeight=100;//Set the image height limit<br> var HeightWidth=img.offsetHeight/img.offsetWidth;//Set the aspect ratio<br> var WidthHeight=img.offsetWidth/img.offsetHeight;//Set the aspect ratio<br> alert("test" img.offsetHeight img.fileSize);<br> if(img.offsetHeight>1) alert(img.offsetHeight);<br> if(img.readyState!="complete"){<br> return false;//Make sure the image is fully loaded <br> }<br> <br> if(img.offsetWidth>MaxWidth){<br> img.width=MaxWidth;<br> img.height=MaxWidth*HeightWidth;<br> if(img.offsetHeight>MaxHeight){<br> img.height=MaxHeight;<br> img.width=MaxHeight*WidthHeight;<br> }<br> }<br> <br> function CheckImg(img)<br> {<br> var message="";<br> var MaxWidth=1;//Set the image width limit<br> var MaxHeight=1;//Set the image height limit<br> <br> if(img.readyState!="complete"){<br> return false;//Make sure the image is fully loaded <br> }<br> if(img.offsetHeight>MaxHeight) message =" Height exceeded:" img.offsetHeight;<br> if(img.offsetWidth>MaxWidth) message =" Width exceeded:" img.offsetWidth;<br> if(message!="") alert(message);<br> }<br> </script>







www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631976.htmlTechArticle? $arr=getimagesize(images/album_01.gif); echo $arr[3]; $strarr=explode (,$arr[3]); echo $strarr[1]; ? HTML HEAD TITLE demo image scaled down/TITLE script function Wa_SetImgAuto...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template