src/utils/convert.js
/**
* Transform canvas coordination according to specified frame size and orientation
* Orientation value is from EXIF tag
*/
Transform canvas coordination according to specified frame size and orientation
Orientation value is from EXIF tag
Transform canvas coordination according to specified frame size and orientation Orientation value is from EXIF tag
function transformCoordinate(canvas, ctx, width, height, orientation) {
  switch (orientation) {
    case 5:
    case 6:
    case 7:
    case 8:
      canvas.width = height;
      canvas.height = width;
      break;
    default:
      canvas.width = width;
      canvas.height = height;
  }
  switch (orientation) {
    case 2:
      ctx.translate(width, 0);
      ctx.scale(-1, 1);
      break;
    case 3:
      ctx.translate(width, height);
      ctx.rotate(Math.PI);
      break;
    case 4:
      ctx.translate(0, height);
      ctx.scale(1, -1);
      break;
    case 5:
       + 90 rotate right
      ctx.rotate(0.5 * Math.PI);
      ctx.scale(1, -1);
      break;
    case 6:
      ctx.rotate(0.5 * Math.PI);
      ctx.translate(0, -height);
      break;
    case 7:
       + 90 rotate right
      ctx.rotate(0.5 * Math.PI);
      ctx.translate(width, -height);
      ctx.scale(-1, 1);
      break;
    case 8:
      ctx.rotate(-0.5 * Math.PI);
      ctx.translate(-width, 0);
      break;
    default:
      break;
  }
}
function transformCoordinate ( canvas , ctx , width , height , orientation ) { switch ( orientation ) { case 5 : case 6 : case 7 : case 8 : canvas . width = height ; canvas . height = width ; break ; default : canvas . width = width ; canvas . height = height ; } switch ( orientation ) { case 2 : ctx . translate ( width , 0 ) ; ctx . scale ( - 1 , 1 ) ; break ; case 3 : ctx . translate ( width , height ) ; ctx . rotate ( Math . PI ) ; break ; case 4 : ctx . translate ( 0 , height ) ; 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 , - height ) ; break ; case 7 : ctx . rotate ( 0.5 * Math . PI ) ; ctx . translate ( width , - height ) ; ctx . scale ( - 1 , 1 ) ; break ; case 8 : ctx . rotate ( - 0.5 * Math . PI ) ; ctx . translate ( - width , 0 ) ; break ; default : break ; } }
Transform canvas coordination according to specified frame size and orientation
Orientation value is from EXIF tag
Transform canvas coordination according to specified frame size and orientation Orientation value is from EXIF tag
// horizontal flip // 180 rotate left // vertical flip // vertical flip + 90 rotate right // 90 rotate right // horizontal flip + 90 rotate right // 90 rotate left