Aspect ratio crop

Crop by aspect ratio or aspect ratio range

Sets target aspect ratio or aspect ratio range when cropping. Aspect ratios can be set as decimal values (1.778) or ratios (16:9).

aspect_ratio=AR | ar=AR

aspect_ratio=AR1,AR2 | ar=AR1,AR2

Crop and resize

If you provide only one dimension parameter (width or height) and aspect_ratio, the other dimension will be calculated. If you include both width and height in the URL, aspect_ratio is ignored.

Examples

Original aspect ratio (3:2 or 1.5): /sample.li/car1.jpg?w=400

Crop without resize

If you provide only aspect_ratio and no dimensions (width or height), the image will be cropped without resizing.

Examples

PreviewSyntax

Original aspect ratio (1.323): /sample.li/frog.png

Aspect ratio range

You can specify a range of aspect ratio values, for example, aspect_ratio=4:3,16:9. Images that fall within this range, will not be cropped. Useful to avoid very wide or very tall images by cropping them to the closest aspect ratio.

Examples

Original aspect ratio 1.5: /sample.li/car1.jpg?w=400

Aspect ratio range 1.5..2 (no crop needed): /sample.li/car1.jpg?w=400&aspect_ratio=1.5,2.0

Original aspect ratio 2.25:1 (2.25): /sample.li/kids.jpg?w=400

Aspect ratio range 3:2..2:1 (1.5..2): /sample.li/kids.jpg?w=400&aspect_ratio=3:2,2:1

Last updated