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.
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
widthandheightare not specified the image size will not be changed.If you use default fit option(
crop) and specify only one side of the image(widthorheight), the unspecified side remains unchanged and you get a cropped image.If you use a fit option other than the default
cropand specify only one side of the image(widthorheight), another side will be defined as auto and the final image will be resized keeping the aspect ratio.When
widthandheightare 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:
"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
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. See the Smart Crop section of this page to learn more.
Outpainting
outpaint Generates a coherent background for an image to fit specified dimensions, scaling an image until the larger side reaches the edge of canvas established by width and height first, so generation happens on either left-right or top-bottom sides symmetrically.
The feathering parameter of the fit object for outpaint type allows you to adjust the smoothness of the transition from the original image content to the generated area. The feathering value is the ratio of the transition area to the total width or height of the input image, depending on what is being resized. In most cases there will be two generated areas on the output image, so "50%" is a limit as it will turn the entire input image into a transition area.
"operations": {
"resizing": {
"width": "150%",
"height": "100%",
"fit": {
"type": "outpaint",
"feathering": "20%"
}
}
}outpaint fit type currently has size limitations: the target image size must not exceed 16.78 Mp (e.g., 4096 x 4096 pixels, 5461 x 3072 pixels). Our team is working on increasing max size
Zoom Out (Outpaint on all sides)
Expands an image in all four directions simultaneously—top, bottom, left, and right. The effect is like zooming out of the original shot, creating a consistent, larger background around the entire image.
To use this, set the fit type to outpaint and provide values for the outpaint_by parameter. You can specify how much to expand in each direction either by percentage of the input image size or by fixed pixel values.
"10%", or
"5% 15%"
string
Fills the space relative to the total image size. Can be specified:
A single value for all sides.
Two values for the horizontal and vertical sides.
❗ The value cannot exceed 50%.
"30px", or
"100px 150px",
string
Fills the space with the exact number of pixels. Can be specified:
As a single value for all sides.
Two values for the horizontal and vertical sides.
❗ The value cannot exceed 50% of the image's width or height, respectively.
The width and height parameters still define the final output size. When using outpaint_by, these values are applied after the outpainted area has been generated.
This means you can:
Control how much padding is added around the image using
outpaint_by.Scale the outpainted result using
widthandheight.
Ensure that the restorations.upscale property is set to an upscaling method of your choice. See Upscale from more info.
"operations": {
"resizing": {
"width": "200%",
"height": "auto",
"fit": {
"type": "outpaint",
"feathering": "20%",
"outpaint_by": "20% 10%"
}
}
}outpaint fit type currently has size limitations: the target image size must not exceed 16.78 Mp (e.g., 4096 x 4096 pixels, 5461 x 3072 pixels). Our team is working on increasing max size
Possible values:
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 or object
Scales an image until the larger side reaches the edge of canvas established by width and height.
cover
string or object
Scales an image until the smaller side reaches the edge of canvas established by width and height.
canvas
string or object
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.
outpaint
string or object
Scales an image until the larger side reaches the edge of canvas established by width and height, then fills the extra space with a generated coherent background.
Examples
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"
}
}
JSON Body
"operations": {
"resizing": {
"width": 1200,
"height": 900,
"fit": "outpaint"
}
}
JSON Body
"operations": {
"resizing": {
"width": "auto",
"height": "auto",
"fit": {
"type": "outpaint",
"outpaint_by": "150px 0px"
}
}
Smart Crop
Fit crop supports center and smart modes for cropping.
center is a basic cropping mode that crops images from their center without considering their content.
smart is a content-aware cropping mode that detects a main object in a photo and uses it as the center point for cropping.

crop: center compared to crop: smartSmart Crop ensures output photos are perfectly framed and focused on the main object.
Last updated


