pad

The pad transformation adds uniform or custom padding around an image with a specified background color. Perfect for creating borders, adding whitespace for design layouts, or preparing images for social media.

Serving Content via CDN

The Media API is a CDN-based service that serves transformed images via GET requests. When you request a transformed image URL, the transformation is applied dynamically on the first request and then cached for subsequent requests.

URL Pattern

https://media.vyso.io/pad:size=SIZE:color=COLOR/ASSET_ID.jpg

Examples

Simple Padding (10px all sides)

curl -i GET https://media.vyso.io/pad:size=10/ASSET_ID.jpg

Standard Padding (20px)

curl -i GET https://media.vyso.io/pad:size=20:color=ffffff/ASSET_ID.jpg

Large Padding with Color

curl -i GET https://media.vyso.io/pad:size=50:color=000000/ASSET_ID.jpg

Custom Sides (different padding)

curl -i GET https://media.vyso.io/pad:left=10:right=10:top=20:bottom=20:color=cccccc/ASSET_ID.jpg

Large Border Padding

curl -i GET https://media.vyso.io/pad:size=100:color=2563eb/ASSET_ID.jpg

On the first request, you'll receive a X-Cache: MISS header while the transformation is applied and cached. Subsequent requests will return X-Cache: HIT.

Parameters

sizeOPTIONAL

Uniform padding on all sides in pixels. Accepted values:

  • Range: 1 to 1000+
  • 10 - Small padding
  • 20 - Standard padding
  • 50 - Large padding
  • Applied to all sides unless overridden by specific parameters
leftOPTIONAL

Left padding in pixels (overrides size).

rightOPTIONAL

Right padding in pixels (overrides size).

topOPTIONAL

Top padding in pixels (overrides size).

bottomOPTIONAL

Bottom padding in pixels (overrides size).

colorOPTIONAL

Padding background color (hex format without #). Accepted values:

  • ffffff - White
  • 000000 - Black
  • cccccc - Light gray
  • Defaults to white if not specified

Response

The API returns the image with padding added. The response format depends on the format of the asset stored in the Vyso asset cloud.

Content-Type: Determined by the stored asset format (e.g., image/jpeg, image/png)