function DrawImage(img, W, H) {
      var image = new Image();
      var i=0
      var imageDest = document.getElementsByName(img)
      for(i=0;i<imageDest.length;i++){
      image.src = imageDest[i].src;
      if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= W / H)//相对显示框：宽>高
        {
          if (image.width > W) //宽度大于显示框宽度W，应压缩高度
          {
            imageDest[i].width = W;
            imageDest[i].height = (image.height * W) / image.width;
          }
          else //宽度少于或等于显示框宽度W，图片完全显示
          {
            imageDest[i].width = image.width;
            imageDest[i].height = image.height;
          }
        }
        else//同理
        {
          if (image.height > H)
          {
            imageDest[i].height = H;
            imageDest[i].width = (image.width * H) / image.height;
          }
          else
          {
            imageDest[i].width = image.width;
            imageDest[i].height = image.height;
          }
        }
      }
    }
    }
