Padding
Last updated
Last updated
With Claid you can control how much space there's around the object. padding
allows you to achieve a consistent look for visuals across your platform. This is an essential operation for eCommerce where the frame around the goods is essential for a visual experience.
There are two main ways to control padding in the Claid API: as a percentage or in pixels.
Value | Type | Description |
---|---|---|
| string | Fills the space relative to the total image size, preserving the actual image size. Can be specified:
The padding cannot be more than half the width/height. |
| string | Fills the space with the exact number of pixels. Can be specified:
The padding for each side of the image can't exceed |
Let's explore the simple example where we just need to add padding around the picture:
In this request, Claid preserves the actual image size, hence squeezing the image and filling the surrounding space with padding.
But let's consider more use cases.
Most eCommerce platforms will require photos to have a white background. Claid has a feature that automatically crops out the product image and leaves the background entirely white.
But it's not enough just to remove the background because the resulting object will be trimmed to borders. Controlling the empty space surrounding the product image would add a more natural look and help meet the platform's requirements.
Let's assume that we need to remove the background and specify the amount of the surrounding space:
We specify the clipping
background removal operation to crop the background up to the foreground object, so the start of padding will be counted from the borders of the object.
If the output sizes are not specified, Claid uses the source width and height, squeezing the shoe to satisfy the padding value.
Also, you can control the color of the background, please see the Background section.
Padding in pixels is used in the same cases as Padding in percentage, but allows for more granular control over the surrounding space.
Suppose you need to remove the background and fix the product to the top. In this case, specifying padding on all sides will give the most accurate result.
Be careful when choosing a #fit, as the canvas
fit additionally fill the padding space to respect the aspect ratio.