Fit

API endpoint - /api/2/img/[IMAGE-URL]/fit?size=[NEW-SIZE]

Description

Fit - resizes, crops, and optimises source image. This operation does not respect original aspect ratio. If you need to preserve aspect ratio then use resize operation.

Parameters

size (required) - new size (in pixels) of the image in the format WIDTHxHEIGHT. You have to specify both dimensions width and height.

dppx (optional) - Number of dots per pixel defines the ratio between device and CSS pixels. The query parameter is a hint that enables extra optimisations for high density screens. The format is a float number in the same format as window.devicePixelRatio.

trim-border(optional) - Will remove the edges of the image with the same color, if the option specified.

Examples

  • size=200x100 - scaling by the smaller side which is height, cropping sides, center positioning

  • dppx=2 - sending a hint to the API that screen has DPI=2

Parameters
Image

Original

size=200x100

size=200x100&dppx=2

Original

size=200x200&trim-border

size=200x200

You can see URL of the examples by "right-click -> Copy Image address"

Last updated