Overview
Sources
Libraries
Images API

Padding padding

Specifies a padding size measured in pixels that will be added to the image.

If you need to specify a padding on specific sides of the image you can use padding-top, padding-right, padding-bottom and padding-left.

Padding will be affected by the value specified by background-color parameter.

Values

This parameter accepts integer values in the range 0 to 500 with 0 disabling padding:

  • 1: specify a padding size of 1 pixel.
  • 500: specify a padding size of 500 pixels.

Padding will be added not increasing size values if specified. In the case that no size is specified padding will be added to the original image size.

Examples

In this example we are specifying a padding of 40 pixels with padding=40. Because the image format does not support transparency and we are not specifying a background-color value the padding will be applied and the default background white color will be see behind the padding area:

GET
https://assets.imglab-cdn.net/woman-03.jpeg?padding=40
Woman posing with a padding of 40 and a default white background color.
x px

For this example we are applying again a padding of 40 pixels with padding=40 and specifying a black background color with background-color=black:

GET
https://assets.imglab-cdn.net/woman-03.jpeg?padding=40&background-color=black
Woman posing with a pdding of 40 and a black background color.
x px

Applying a padding to a image format with alpha transparency support without specifying background-color will result in a transparent padding:

GET
https://assets.imglab-cdn.net/woman-03.jpeg?padding=40&format=png
Woman posing with a padding of 40 and a default transparent background color using png as output format.
x px

If we specify a background color with alpha component and the output format supports alpha transparency we will see a padding with alpha. In this example we are applying a padding of 40 pixels with padding=40 and a transparent background color with background-color=2B493E80:

GET
https://assets.imglab-cdn.net/woman-03.jpeg?padding=40&background-color=2B493E80&format=png
Woman posing image with a padding of 40 and a semi-transparent background color using png as output format.
x px