function DrawImage(ImgD,width, height){ 
 var img = new Image();
 img.src =  ImgD.src;
 if(img.width>0 && img.height>0 ){ 
   if(width != '' && height!=''){
      ImgD.width=width;
      ImgD.height=height;

   }
   else if(width != ''  ){
       if (width < img.width){
            var heightNew = img.height * (width/ img.width ) ;
            ImgD.height = heightNew ;
            ImgD.width = width;
       }
       else {
           ImgD.width = img.width;
       }
  }
 }
}