Skip to content

Instantly share code, notes, and snippets.

@andion
Last active May 17, 2020 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andion/9b6f617d1ce3051288717784e20f78e3 to your computer and use it in GitHub Desktop.
Save andion/9b6f617d1ce3051288717784e20f78e3 to your computer and use it in GitHub Desktop.
const {
sx,
sy,
sWidth,
sHeight,
dx,
dy,
dWidth,
dHeight,
canvasWidth,
canvasHeight,
} = getAspectRatioParams(originalWidth, originalHeight, transformedRatio);
canvas.width = canvasWidth;
canvas.height = canvasHeight;
ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment