/**
 * 图像处理模块
 */
var PIC_MAX_WIDTH = 800;
var PIC_MAX_HEIGHT = 900;
var scaleVar = 1000;
function showPic() {
    var width = PIC_MAX_WIDTH;
    var height = PIC_MAX_HEIGHT;
    var img = document.getElementById("imgPreview");
    //alert(img.width);
    //alert(img.height);
    if (img.width < width && img.height < height) {//如果两边都小于标准宽度,那么原图显示,不拉伸也不压缩
        return;
    }
    var mode = img.height * width > img.width * height ? 1 : 2;
    switch (mode) {
      case 2:
        img.height = Math.round(img.height * width * scaleVar / img.width) / scaleVar;
        img.width = width;
        break;
      case 1:
        img.width = Math.round(img.width * height * scaleVar / img.height) / scaleVar;
        img.height = height;
        break;
    }
}
setTimeout(showPic,1000);

