How the image resizer works
The browser decodes each selected image, calculates the requested output dimensions, draws the pixels onto a new canvas with high-quality smoothing, and encodes a metadata-free JPEG, PNG, or WebP file.
output height = source height × output width ÷ source widthAspect-locked resizing applies one scale factor to both dimensions; exact mode can change width and height independently.
Resize a 2400 × 1600 image to 1200 pixels wide
With the aspect ratio preserved, the scale factor is 0.5 and the output becomes 1200 × 800 pixels. Prevent-upscale mode leaves images smaller than the requested width at their original dimensions.
Using the processed image
Keep the exported dimensions, format, transparency, and compression level appropriate for where the image will be used.
canvas.width = outputWidth;
canvas.height = outputHeight;
context.drawImage(bitmap, 0, 0, outputWidth, outputHeight);const outputHeight = Math.round(
sourceHeight * outputWidth / sourceWidth
);Using the result accurately
Resize to the largest dimensions the final layout actually needs. Keep the aspect ratio locked for photographs and interface assets unless intentional distortion is required, and inspect text or fine detail after a large reduction.
Upscaling cannot restore missing detail. Browser encoders can produce slightly different file sizes, color output, and compression artifacts, and generated files do not retain EXIF, camera, location, or resolution metadata.
References: MDN CanvasRenderingContext2D drawImage().