Width and height in pixels
64-bitThe pixel size of the picture.
h = round(w × vh ÷ vw); k = min(1, MAX ÷ w, MAX ÷ h)
The proportion is multiplied before it is divided, then rounded once; a scale-down rounds a second time, so the shape can change by up to one pixel.
/** The picture's size: width and height as given (one of them: the view's shape), else the dialog's size setting. */
export function renderSize(settings, view, a = {}) {
const vw = Math.max(1, view?.w || 1), vh = Math.max(1, view?.h || 1);
let w, h;
if (a.width && a.height) { w = a.width; h = a.height; }
else if (a.width) { w = a.width; h = Math.round((a.width * vh) / vw); }
else if (a.height) { h = a.height; w = Math.round((a.height * vw) / vh); }
else return sizeFor(settings, vw, vh);
const k = Math.min(1, MAX_SIDE / w, MAX_SIDE / h);
return { w: Math.max(1, Math.round(w * k)), h: Math.max(1, Math.round(h * k)) };
}