Image Cropper — aspect ratio presets, free in your browser
Trim a JPG, PNG, or WebP image to a 1:1, 4:3, 16:9, 9:16, golden, or free-form rectangle entirely in your browser. Drag the corners, nudge with arrow keys, or type exact pixel coordinates — files never leave your device.
How it works
Cropping on the web has been a single-call canvas operation since the original HTML5 spec shipped. The tool above wires up the three-step pipeline that every modern browser supports: decode the source file into an HTMLImageElement, copy a sub-rectangle of those pixels into an off-screen canvas with the 9-argument form of drawImage, then encode the canvas back to a file with canvas.toBlob. No part of the file leaves the tab.
The mathematically interesting step is the planning: given a source size and a target aspect ratio, how exactly should the crop rectangle land on the source? The primary formula uses the limiting axis. Compare the source width-to-height ratio with the target ratio:
src_aspect = source_width / source_height
if src_aspect >= target_aspect:
crop_height = source_height
crop_width = round(crop_height * target_aspect)
else:
crop_width = source_width
crop_height = round(crop_width / target_aspect)
crop_x = round((source_width - crop_width) / 2)
crop_y = round((source_height - crop_height) / 2)A second, independent formula solves the same problem from the width-first side: assume the crop spans the entire source width, then shrink to height if the implied height would overflow the source. Both formulas produce the same integer width and height to within 1 px of rounding slack on every input the tool accepts. The Cross-check panel inside the calculator above shows both numbers side by side so you can verify they agree on your own image.
Free-form mode skips the aspect-ratio constraint. The four corner handles each move independently within the source bounds, with a minimum crop size of 8 × 8 px so the rectangle is always visible. When you switch back to an aspect preset, the current rectangle is reshaped around its existing centre so you don't lose your framing.
Encoding uses the same path the Image Resizer tool relies on: canvas.toBlob(callback, mime, quality). JPEG quality is fixed at 0.92 — high enough that re-encoded photos are visually indistinguishable from the source, low enough that the output file isn't larger than the input. PNG and WebP are lossless / near-lossless and ignore the quality argument. The source-rect and destination-rect dimensions in the drawImage call are identical, so no resampling happens — kept pixels reach the encoder unchanged.
Worked examples
Aspect ratio presets
Each preset chip on the tool maps to a fixed width-to-height ratio. The right column shows what the maximum centred crop looks like on a 4032 × 3024 phone photo for comparison.
| Preset | Ratio | Max crop on 4032 × 3024 |
|---|---|---|
| 1:1 Square | 1.000 : 1 | 3,024 × 3,024 @ (504, 0) |
| 4:3 Classic | 1.333 : 1 | 4,032 × 3,024 @ (0, 0) |
| 3:2 Photo | 1.500 : 1 | 4,032 × 2,688 @ (0, 168) |
| 16:9 Widescreen | 1.778 : 1 | 4,032 × 2,268 @ (0, 378) |
| 9:16 Vertical | 0.563 : 1 | 1,701 × 3,024 @ (1,166, 0) |
| 3:4 Portrait | 0.750 : 1 | 2,268 × 3,024 @ (882, 0) |
| 2:3 Portrait | 0.667 : 1 | 2,016 × 3,024 @ (1,008, 0) |
| 21:9 Ultrawide | 2.333 : 1 | 4,032 × 1,728 @ (0, 648) |
| 1.618 Golden | 1.618 : 1 | 4,032 × 2,492 @ (0, 266) |
Frequently asked questions
Sources & references
- MDN — CanvasRenderingContext2D.drawImage (9-arg source-rect form)
- MDN — HTMLCanvasElement.toBlob (browser-native encoder)
- MDN — Pointer events (unified mouse / touch / pen handling)
- Adobe — The golden ratio definition (1 : 1.618)
- WHATWG HTML — accept attribute on file inputs
Canvas behaviour and ratio definitions were last cross-checked against the above sources on 2026-05-11. The page is reviewed twice a year and whenever the Canvas spec changes the toBlob / drawImage contract.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.