Skip to main content

Edit Images

POST /v1/images/edit

Perform editing operations on images including resize, crop, watermark, format conversion, and filters.

Request

FieldTypeRequiredDescription
srcstringYesSource image URL
operationsarrayYesList of operations to apply in order
outputobjectNoOutput format options

Resize

curl -X POST https://api.vidiking.com/v1/images/edit \
-H "Authorization: Bearer $VIDIKING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"src": "https://example.com/photo.jpg",
"operations": [
{ "type": "resize", "width": 800, "height": 600, "fit": "cover" }
],
"output": { "format": "webp", "quality": 85 }
}'

Node.js

const result = await client.images.edit({
src: 'https://example.com/photo.jpg',
operations: [
{ type: 'resize', width: 800, height: 600, fit: 'cover' },
],
output: { format: 'webp', quality: 85 },
});

console.log(result.url);

Python

result = client.images.edit(
src="https://example.com/photo.jpg",
operations=[
{"type": "resize", "width": 800, "height": 600, "fit": "cover"},
],
output={"format": "webp", "quality": 85},
)
print(result.url)

Crop

{
"src": "https://example.com/photo.jpg",
"operations": [
{ "type": "crop", "x": 100, "y": 50, "width": 800, "height": 600 }
]
}

Watermark

{
"src": "https://example.com/photo.jpg",
"operations": [
{
"type": "watermark",
"image": "https://example.com/logo.png",
"position": "bottom-right",
"opacity": 0.5,
"scale": 0.15,
"padding": 20
}
]
}

Watermark positions: top-left, top-center, top-right, center, bottom-left, bottom-center, bottom-right.

Filters

{
"src": "https://example.com/photo.jpg",
"operations": [
{ "type": "filter", "name": "grayscale" }
]
}

Available filters:

FilterDescription
grayscaleConvert to grayscale
sepiaApply sepia tone
blurGaussian blur (use amount for intensity)
sharpenSharpen the image
brightnessAdjust brightness (use amount: -100 to 100)
contrastAdjust contrast (use amount: -100 to 100)
saturateAdjust saturation (use amount: -100 to 100)

Chaining Operations

Apply multiple operations in sequence:

curl -X POST https://api.vidiking.com/v1/images/edit \
-H "Authorization: Bearer $VIDIKING_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"src": "https://example.com/photo.jpg",
"operations": [
{ "type": "resize", "width": 1200, "height": 1200, "fit": "cover" },
{ "type": "filter", "name": "brightness", "amount": 10 },
{ "type": "filter", "name": "contrast", "amount": 15 },
{ "type": "watermark", "image": "https://example.com/logo.png", "position": "bottom-right", "opacity": 0.4 }
],
"output": { "format": "png" }
}'

Format Conversion

Convert between image formats by specifying the output format:

{
"src": "https://example.com/photo.png",
"operations": [],
"output": { "format": "webp", "quality": 90 }
}

Supported formats: jpg, png, webp, gif, avif.

Response

{
"id": "edit_abc123",
"url": "https://cdn.vidiking.com/images/edit_abc123.webp",
"width": 800,
"height": 600,
"format": "webp",
"file_size": 45200,
"credits_used": 1,
"created_at": "2025-01-15T10:30:00Z"
}

Cost

Image editing operations cost 1 credit per request regardless of the number of operations applied.