code: function orientationHelper(canvas, ctx, orientation) {
      const w = canvas.width, h = canvas.height;
      if(orientation > 4){
          canvas.width = h;
          canvas.height = w;
      }
      switch (orientation) {
          case 2:
              ctx.translate(w, 0);
              ctx.scale(-1, 1);
              break;
          case 3:
              ctx.translate(w, h);
              ctx.rotate(Math.PI);
              break;
          case 4:
              ctx.translate(0, h);
              ctx.scale(1, -1);
              break;
          case 5:
              ctx.rotate(0.5 * Math.PI);
              ctx.scale(1, -1);
              break;
          case 6:
              ctx.rotate(0.5 * Math.PI);
              ctx.translate(0, -h);
              break;
          case 7:
              ctx.rotate(0.5 * Math.PI);
              ctx.translate(w, -h);
              ctx.scale(-1, 1);
              break;
          case 8:
              ctx.rotate(-0.5 * Math.PI);
              ctx.translate(-w, 0);
              break;
      }
  }
docs: 修正拍照时图片的方向
  ref to http://stackoverflow.com/questions/19463126/how-to-draw-photo-with-correct-orientation-in-canvas-after-capture-photo-by-usin