var flag=false;

function ModifyImage(ImgD,w,h){
	var image=new Image();
	var FitWidth=w;  //圖片的最大寬度，超過這個值就會自動縮小
	var FitHeight=h; //依照比例縮小
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
		flag=true;
		if(image.width/image.height>= FitWidth/FitHeight){
			if(image.width>FitWidth){
				ImgD.width=FitWidth;
				ImgD.height=(image.height*FitWidth)/image.width;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt="";
		}else{
			if(image.height>FitHeight){
				ImgD.height=FitHeight;
				ImgD.width=(image.width*FitHeight)/image.height;
			}else{
				ImgD.width=image.width;
				ImgD.height=image.height;
			}
			ImgD.alt="";
		}
	}
}