← Back to projects
PROJECT / 06Personal lab
Image preparation
Resize and adjust an image in the browser.
WEB PROTOTYPE
Use the sample image or open your own. Processing happens locally and exports PNG. This demo does not apply AI upscaling.
View concept code
export function outputSize(w, h, width) {
if (![w, h, width].every((n) => Number.isFinite(n) && n > 0)) throw Error('Invalid image size');
const ratio = Math.min(width / w, 1600 / w, 1600 / h);
return { width: Math.max(1, Math.round(w * ratio)), height: Math.max(1, Math.round(h * ratio)) };
}