function calcSize(w, h, limitW, limitH) {
if (h <= limitH && w <= limitW) {
return [w, h];
}
const r = Math.min(limitW / w, limitH / h);
return [Math.round(r * w), Math.round(r * h)];
}
const realSizes = calcSize(imgW, imgH, Infinity, 200);