code: function (img, w, h, type) {
              var ow = img.width,
                  oh = img.height;
  
              if (type == 'justify') {
                  if (ow >= oh) {
                      img.width = w;
                      img.height = h * oh / ow;
                      img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
                  } else {
                      img.width = w * ow / oh;
                      img.height = h;
                      img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
                  }
              } else {
                  if (ow >= oh) {
                      img.width = w * ow / oh;
                      img.height = h;
                      img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
                  } else {
                      img.width = w;
                      img.height = h * oh / ow;
                      img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
                  }
              }
          }
docs: /* 改变图片大小