﻿// JScript 文件
function SetImageSize(ImgD,newWidth,newHeight)
{
  var image=new Image();
  image.src=ImgD.src;
  if(image.width>0 && image.height>0)
  {
	  if(image.width>newWidth || image.height>newHeight)
	  {
		  if ((image.width/newWidth) > (image.height/newHeight))
		  {
			  	ImgD.width=newWidth;
		  		ImgD.height=(newWidth/image.width)*image.height;
		  }
		  else
		  {
				ImgD.height=newHeight;
		    	ImgD.width=(newHeight/image.height)*image.width;
		  }		  
	  }    
  }
} 

