Image Padding
Add solid-colour padding to any side of an image
GET
10 credits
/v1/image/pad
curl "https://image.toolkitapi.io/v1/image/pad?url=https://toolkitapi.io/static/samples/sample-image.png&top=50&right=50&bottom=50&left=50&fill_color=%23ffffff"
import httpx
resp = httpx.get(
"https://image.toolkitapi.io/v1/image/pad?url=https://toolkitapi.io/static/samples/sample-image.png&top=50&right=50&bottom=50&left=50&fill_color=%23ffffff",
)
print(resp.json())
const resp = await fetch("https://image.toolkitapi.io/v1/image/pad?url=https://toolkitapi.io/static/samples/sample-image.png&top=50&right=50&bottom=50&left=50&fill_color=%23ffffff", {
});
const data = await resp.json();
console.log(data);
# See curl example
Response
200 OK
{
"image": "iVBORw0KGgoAAAANSUhEUg...(base64 data)...",
"format": "png",
"original_size": {"width": 800, "height": 600},
"new_size": {"width": 900, "height": 700}
}
Try It Live
Live Demo
Response
Description
Add solid-colour padding to any side of an image
How to Use
1
1. Provide the source image via the `url` query parameter.
2
2. Set `top`, `right`, `bottom`, and `left` padding values in pixels (0–2000 each).
3
3. Choose a `fill_color` (hex) for the padding area.
4
4. The response includes original and new dimensions.
About This Tool
Use the Image Padding endpoint to add solid-colour borders around any image. Each side (top, right, bottom, left) can be set independently, giving you precise control over canvas expansion.
This is useful for adding margins before printing, creating letterbox effects, making square images from non-square originals, and adding breathing room around content for social media posts.
Why Use This Tool
- Print margins — Add bleed area for print-ready images
- Square framing — Add asymmetric padding to make non-square images square
- Social media borders — Add coloured borders for Instagram or Pinterest posts
- Letterboxing — Add cinematic black bars to widescreen content
- Canvas expansion — Grow an image's canvas for composition work
Frequently Asked Questions
Can I add transparent padding?
The fill colour is a solid RGB hex value. For transparent padding, use PNG format and composite the image onto a transparent canvas using the Composite endpoint.
Is there a maximum padding size?
Each side can have up to 2000 pixels of padding. The total image dimensions after padding must not exceed practical limits.
Can I use this to make an image a specific size?
Yes. Calculate the required padding: for example, to center a 600×400 image in an 800×800 canvas, set top=200, bottom=200, left=100, right=100.
Start using Image Padding now
Get your free API key and make your first request in under a minute.