Skip to main content

Resize an image

Resize transformation allows users to change the dimensions of an image. This can be done to make the image larger or smaller, to fit a certain aspect ratio, or to create different versions of the same image for different purposes.

Resize your images by setting the width and/or height parameters, using different crop parameters like a cover, fill, etc.

When resizing an image, it's important to be careful not to distort the aspect ratio or lose too much detail. Enlarging an image beyond its original size can lead to pixelation and blurriness while shrinking an image too much can result in a loss of detail and clarity. To minimize these issues, it's best to resize an image in small increments, rather than making large changes all at once.


Params

Height (h)

This parameter sets the height of the output image.

If this parameter is omitted, and the width parameter is set, the output height is set automatically such that the aspect ratio is preserved.

The maximum value for this is 10000 and any output which has more than this height will be scaled down to this value.

Width (w)

This parameter sets the width of the output image.

If this parameter is omitted, and the height parameter is set, the output width is set automatically such that the aspect ratio is preserved.

The maximum value for this is 10000 and any output which has more than this width will be scaled down to this value.

Fit (f)

Resize to fit within boundaries specified by width and height parameters.

When both a width and height are provided, the possible methods by which the image should fit these are:

  • cover: (default) Preserving aspect ratio, ensure the image covers both provided dimensions by cropping/clipping to fit.
  • contain: Preserving aspect ratio, contained within both provided dimensions using "letterboxing" where necessary.
  • fill: Ignore the aspect ratio of the input and stretch to both provided dimensions.
  • inside: Preserving the aspect ratio, resizing the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
  • outside: Preserving the aspect ratio, resizing the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.

Position (p)

Position the image when the original aspect ratio is different from the resultant one.

When using a fit of cover or contain, the default position is center. All the valid options are top, right_top, right, right_bottom, bottom, left_bottom, left, left_top, center.