﻿function imgresize(ImgD,Width,Height)
{ 
var image=new Image(); 
image.src=ImgD.src; 
if(image.width>0 && image.height>0)
{ 
flag=true; 
if(image.width/image.height>= Width/Height)
{ 
if(image.width>Width)
{ 
ImgD.width=Width; 
ImgD.height=(image.height*Height)/image.width; 
}
else
{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
} 
else
{ 
if(image.height>Height)
{ 
ImgD.height=Height; 
ImgD.width=(image.width*Height)/image.height; 
}
else
{ 
ImgD.width=image.width; 
ImgD.height=image.height; 
} 
} 
} 
} 