php 擷取圖片尺寸

來源:互聯網
上載者:User

 
<?
$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 img=document.all.img1;//擷取圖片
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+="r高度超額:"+img.offsetHeight;
 if(img.offsetWidth>MaxWidth) message+="r寬度超額:"+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>
 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.