天天看點

img制作等比例縮略圖

img制作等比例縮略圖

< script >

img制作等比例縮略圖
img制作等比例縮略圖

function  AutoSize(ImgD,MaxWidth,MaxHeight) ... {

img制作等比例縮略圖

   var image=new Image();

img制作等比例縮略圖

   image.src=ImgD.src;

img制作等比例縮略圖
img制作等比例縮略圖

   if(image.width>0 && image.height>0)...{

img制作等比例縮略圖

    flag=true;

img制作等比例縮略圖
img制作等比例縮略圖

    if(image.width/image.height>= MaxWidth/MaxHeight)...{

img制作等比例縮略圖
img制作等比例縮略圖

     if(image.width>MaxWidth)...{  

img制作等比例縮略圖

     ImgD.width=MaxWidth;

img制作等比例縮略圖

     ImgD.height=(image.height*MaxWidth)/image.width;

img制作等比例縮略圖
img制作等比例縮略圖

     }else...{

img制作等比例縮略圖

     ImgD.width=image.width;  

img制作等比例縮略圖

     ImgD.height=image.height;

img制作等比例縮略圖

     }

img制作等比例縮略圖

     //ImgD.alt="原始尺寸:寬" + image.width+",高"+image.height;

img制作等比例縮略圖

     }

img制作等比例縮略圖
img制作等比例縮略圖

    else...{

img制作等比例縮略圖
img制作等比例縮略圖

     if(image.height>MaxHeight)...{  

img制作等比例縮略圖

     ImgD.height=MaxHeight;

img制作等比例縮略圖

     ImgD.width=(image.width*MaxHeight)/image.height;     

img制作等比例縮略圖
img制作等比例縮略圖

     }else...{

img制作等比例縮略圖

     ImgD.width=image.width;  

img制作等比例縮略圖

     ImgD.height=image.height;

img制作等比例縮略圖

     }

img制作等比例縮略圖

     //ImgD.alt="原始尺寸:寬" + image.width+",高"+image.height;

img制作等比例縮略圖

     }

img制作等比例縮略圖

    }

img制作等比例縮略圖

   }  

img制作等比例縮略圖

</ script >

img制作等比例縮略圖
img制作等比例縮略圖

< img src = " DNS.gif "  onload = " AutoSize(this,200,200) "  style = " cursor:pointer "  alt = " 在新視窗打開 "  onclick = " window.open(this.src) " />  

繼續閱讀