Search…
⌃K

Resizing

The Claid API allows you to set the final image size for different workflows you may have. By default, API will perform all calculations respecting the original image aspect ratio. Meaning, the image can be cropped but it won't be stretched or squeezed.
When you need a size bigger than the original image, you can use upscale parameter to increase the final image resolution

Width and Height

Specifies the size of the output image. The width and height parameter supports dynamic sizing and is based on pixels or percent values.

The default behavior of API resizing

  • If width and height are not specified the image size will not be changed.
  • If you use default fit option(crop) and specify only one side of the image(width or height), the unspecified side remains unchanged and you get a cropped image.
  • If you use a fit option other than the default crop and specify only one side of the image(width or height), another side will be defined as auto and the final image will be resized keeping the aspect ratio.
  • When width and height are specified the resulting image will be resized until it fully covers the specified dimensions and gets cropped.
The default behavior can be changed by the fit property.
Acceptable values:
Value
Type
Description
"auto"
string
The dimension will be calculated automatically to save the aspect ratio of the input image. Both width and height cannot be set to auto. When using auto, specify at least one of the dimensions in pixels or percentages.
1000
integer
width or height in pixels.
"200%"
string
Percentage as a string. E.g. "200%" means that the dimension will double relative to the input image.

Examples

You can read more about "fit": "bounds", which is used in the following examples in Fit section
Empty
Auto
Pixels
Percentage
JSON Body
"operations": {
"resizing": {
"width": 4000,
"fit": "bounds"
}
}
JSON Body
"operations": {
"resizing": {
"width": "auto",
"height": 4000,
"fit": "bounds"
}
}
JSON Body
"operations": {
"resizing": {
"width": 4000,
"height": 4000,
"fit": "bounds"
}
}
JSON Body
"operations": {
"resizing": {
"width": "200%",
"height": "200%",
"fit": "bounds"
}
}

Fit

The fit parameter controls how the image will be constrained within the provided size, relative to the width and height. Check the image examples below to see how fit works.
Possible properties:
bounds Preserves the aspect ratio. Resize the image to fit entirely within the specified region, making one dimension smaller if needed.
cover Preserving aspect ratio. Resize the image to entirely cover the specified region, making one dimension larger if needed.
canvas Input image will be placed on the canvas established by width and height. The aspect ratio of the input image won’t change. Extra space will be filled with the background color.
crop Scales an image until it fully covers the specified dimensions. the rest gets cropped. Fit crop support center and smart modes for cropping.
Possible values:
Value
Type
Description
crop
string or object
DEFAULT. Scales an image until it fully covers the specified width and height, the rest gets cropped. Content-aware cropping.
bounds
string
Scales an image until the larger side reaches the edge of canvas established by width and height.
cover
string
Scales an image until the smaller side reaches the edge of canvas established by width and height.
canvas
string
Puts input image on the canvas established by width and height. Aspect ratio and size of the input image won't change. Extra space will be filled with the specified background color.

Examples

Crop
Bounds
Cover
Canvas
JSON Body
"operations": {
"resizing": {
"width": 1440,
"height": 1440,
"fit": "crop"
}
}
JSON Body
"operations": {
"resizing": {
"width": 1440,
"height": 1440,
"fit": "bounds"
}
}
JSON Body
"operations": {
"resizing": {
"width": 1440,
"height": 1440,
"fit": "cover"
}
}

JSON Body

"operations": {
"resizing": {
"width": 1440,
"height": 1440,
"fit": "canvas"
}
}

Smart Crop

Fit crop supports center and smart modes for cropping.
Center
Smart
JSON Body
"operations": {
"resizing": {
"width": 1440,
"height": 1440,
"fit": {
"crop": "center"
}
}
}

JSON Body
"operations": {
"resizing": {
"width": 2000,
"height": 2000,
"fit": {
"crop": "smart"
}
}
}