Resize an image to target dimensions while optionally preserving its aspect ratio.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
The source bitmap is sampled into a destination width and height using an interpolation filter; preserving aspect ratio derives one dimension from the other. Resampling changes pixel count and cannot restore detail lost in a smaller source.
Input: data:image/png;base64,iVBORw0KGgo= Width: 800 Height: 600 Maintain aspect ratio: true
PNG data URL scaled to fit within an 800×600 box without stretching
Responsive thumbnails, upload optimization, and raster exports resize images.