Processing and Filters

Day-to-day image transformations: resize, crop, rotate, compress, remove backgrounds, apply filters, and adjust brightness/contrast/saturation.

Endpoints

Core processing

Method Endpoint Purpose
POST /v1/image/resize Resize to target dimensions
POST /v1/image/crop Crop by coordinates, smart center, or square
POST /v1/image/rotate Rotate by any angle
POST /v1/image/flip Flip horizontally or vertically
POST /v1/image/compress Reduce image file size
POST /v1/image/strip-exif Remove metadata for privacy
POST /v1/image/trim Auto-trim borders
POST /v1/image/pad Add padding or borders
POST /v1/image/composite Overlay one image onto another
POST /v1/image/dither Reduce to a limited colour palette
POST /v1/image/remove-background Remove image backgrounds

Filters and adjustments

Method Endpoint Purpose
POST /v1/image/filter/grayscale Convert to grayscale
POST /v1/image/filter/blur Apply Gaussian blur
POST /v1/image/filter/sharpen Sharpen the image
POST /v1/image/filter/sepia Apply sepia tone
POST /v1/image/adjust/brightness Adjust brightness
POST /v1/image/adjust/contrast Adjust contrast
POST /v1/image/adjust/saturation Adjust saturation

Examples

Resize an image

curl -X POST "https://image.toolkitapi.io/v1/image/resize" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/photo.jpg", "width": 800, "maintain_aspect": true, "format": "jpeg"}'
import requests
import base64

resp = requests.post(
    "https://image.toolkitapi.io/v1/image/resize",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"url": "https://example.com/photo.jpg", "width": 800, "maintain_aspect": True, "format": "jpeg"},
)
data = resp.json()
# data["image"] contains base64-encoded result
with open("resized.jpg", "wb") as f:
    f.write(base64.b64decode(data["image"]))
print(f"Resized: {data['original_width']}x{data['original_height']} → {data['width']}x{data['height']}")
const resp = await fetch("https://image.toolkitapi.io/v1/image/resize", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com/photo.jpg", width: 800, maintain_aspect: true, format: "jpeg" }),
});
const data = await resp.json();
console.log(`Resized to ${data.width}x${data.height}`);

Remove background

curl -X POST "https://image.toolkitapi.io/v1/image/remove-background" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/product.jpg", "format": "png"}'
import requests
import base64

resp = requests.post(
    "https://image.toolkitapi.io/v1/image/remove-background",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"url": "https://example.com/product.jpg", "format": "png"},
)
data = resp.json()
with open("product-no-bg.png", "wb") as f:
    f.write(base64.b64decode(data["image"]))
const resp = await fetch("https://image.toolkitapi.io/v1/image/remove-background", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ url: "https://example.com/product.jpg", format: "png" }),
});
const data = await resp.json();
// data.image is base64 PNG with transparent background

Upload via base64 (alternative to URL)

curl -X POST "https://image.toolkitapi.io/v1/image/compress" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image": "BASE64_ENCODED_IMAGE_DATA", "quality": 75}'
import requests
import base64

with open("large-photo.jpg", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()

resp = requests.post(
    "https://image.toolkitapi.io/v1/image/compress",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"image": b64, "quality": 75},
)
data = resp.json()
print(f"Compressed: {data['original_size_bytes']} → {data['size_bytes']} bytes")
import fs from "fs";

const image = fs.readFileSync("large-photo.jpg").toString("base64");
const resp = await fetch("https://image.toolkitapi.io/v1/image/compress", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_KEY", "Content-Type": "application/json" },
  body: JSON.stringify({ image, quality: 75 }),
});
const data = await resp.json();
console.log(`Compressed: ${data.original_size_bytes} → ${data.size_bytes} bytes`);

Apply filters

curl -X POST "https://image.toolkitapi.io/v1/image/filter/blur" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/photo.jpg", "radius": 5, "format": "png"}'
import requests

# Grayscale
resp = requests.post(
    "https://image.toolkitapi.io/v1/image/filter/grayscale",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"url": "https://example.com/photo.jpg", "format": "png"},
)

# Adjust brightness
resp = requests.post(
    "https://image.toolkitapi.io/v1/image/adjust/brightness",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"url": "https://example.com/photo.jpg", "value": 1.2, "format": "jpeg"},
)

Common parameters

All image endpoints accept images via either url (public URL) or image (base64-encoded string). Most support an output_format parameter to control the response format.

Parameter Type Description
url string Public URL to the source image
image string Base64-encoded image data (alternative to url)
format string Output format: png, jpeg, webp, gif, bmp, tiff
quality integer Output quality 1–100 (JPEG/WebP). Default: 85

Resize-specific

Parameter Type Description
width integer Target width in pixels (1–10000)
height integer Target height in pixels (1–10000)
maintain_aspect boolean Maintain aspect ratio. Default: true

Tip

Use image compression before serving images in production. The compress endpoint balances quality and file size — ideal for reducing bandwidth in image-heavy applications.