UNPKG

634 BJavaScriptView Raw
1export function getScaledDimensions(width, height, maxSize) {
2 if (height >= width) {
3 if (height <= maxSize) {
4 // if image already smaller than the required height
5 return { width, height };
6 }
7 return {
8 width: Math.round((maxSize * width) / height),
9 height: maxSize,
10 };
11 }
12 if (width <= maxSize) {
13 // if image already smaller than the required width
14 return { width, height };
15 }
16 return {
17 width: maxSize,
18 height: Math.round((maxSize * height) / width),
19 };
20}
21//# sourceMappingURL=image-source-common.js.map
\No newline at end of file