Created
October 29, 2018 14:44
-
-
Save mCzolko/87c429e2068c847f144c1fcb0f9fb352 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CANVAS_WIDTH = 1000; | |
const CANVAS_HEIGHT = 800; | |
function resizeImage(imageWidth, imageHeight) { | |
const ratio = imageWidth / imageHeight; | |
let width = CANVAS_WIDTH; | |
let height = width / ratio; | |
if (height > CANVAS_HEIGHT) { | |
height = CANVAS_HEIGHT; | |
width = height * ratio; | |
} | |
return { | |
width, | |
height, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment