用PHP或JS獲取圖片大小,高寬尺寸
來源:程序員人生 發布時間:2013-10-30 16:13:31 閱讀次數:2520次
- <?php
- $arr=getimagesize("images/album_01.gif");
- echo $arr[3];
- $strarr=explode(""",$arr[3]);
- echo $strarr[1];
- ?>
- <HTML>
-
- <HEAD>
- <TITLE>演示圖片等比例縮小</TITLE>
- <script>
- function Wa_SetImgAutoSize(img)
- {
-
- var MaxWidth=200;
- var MaxHeight=100;
- var HeightWidth=img.offsetHeight/img.offsetWidth;
- var WidthHeight=img.offsetWidth/img.offsetHeight;
- alert("test" img.offsetHeight img.fileSize);
- if(img.offsetHeight>1) alert(img.offsetHeight);
- if(img.readyState!="complete"){
- return false;
- }
-
- if(img.offsetWidth>MaxWidth){
- img.width=MaxWidth;
- img.height=MaxWidth*HeightWidth;
- if(img.offsetHeight>MaxHeight){
- img.height=MaxHeight;
- img.width=MaxHeight*WidthHeight;
- }
- }
-
- function CheckImg(img)
- {
- var message="";
- var MaxWidth=1;
- var MaxHeight=1;
-
- if(img.readyState!="complete"){
- return false;
- }
- if(img.offsetHeight>MaxHeight) message =" 高度超額:" img.offsetHeight;
- if(img.offsetWidth>MaxWidth) message =" 寬度超額:" img.offsetWidth;
- if(message!="") alert(message);
- }
- </script>
- </HEAD>
- <BODY>
- <img src="images/frequency.gif" border=0 id="img1" onload="CheckImg(this);">
- <br>
- <input id=inp type="file" onpropertychange="img1.src=this.value;">
- </BODY>
- </HTML>
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
------分隔線----------------------------
------分隔線----------------------------