Merge Images
Data Generator Image Generator Credits / request: 5Merges multiple images horizontally or vertically.
POST
https://api.apikodu.com/api/v1/imagegenerator/merge
Documentation
Overview
Places a foreground image on a background image.
Authentication
Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).
Request
POST
https://api.apikodu.com/api/v1/imagegenerator/merge
JSON body; both images are sent from files in the playground.
Parameters
| Name | Type | Required | Default | Options | Description |
|---|---|---|---|---|---|
backgroundImageBase64 |
string | * Required | — | — | Background (base64). |
foregroundImageBase64 |
string | * Required | — | — | Foreground (base64). |
position |
string | Optional | Center |
TopLeft TopCenter TopRight CenterLeft Center CenterRight BottomLeft BottomCenter BottomRight |
Position. |
sizePercent |
integer | Optional | 25 |
— | Foreground size as % of the background short edge. |
borderWidth |
integer | Optional | 0 |
— | Foreground border width. |
backdropColor |
string | Optional | #FFFFFF |
— | Border/backdrop color. |
marginPercent |
integer | Optional | 0 |
— | Edge margin percent. |
outputFormat |
string | Optional | — | png jpeg webp |
Empty → png. |
quality |
integer | Optional | 90 |
— | JPEG/WebP quality 1–100. |
Response
| Name | Type | Description |
|---|---|---|
downloadUrl |
string | Signed download URL. Becomes invalid after expires. |
format |
string | Output format: png, jpeg or webp. |
width |
integer | Output width in pixels. |
height |
integer | Output height in pixels. |
sizeBytes |
integer | Output file size in bytes. |
expires |
number | Unix epoch expiry of the download URL (seconds). |
Errors
| HTTP | code | Description |
|---|---|---|
400 |
-204 |
Image missing, invalid base64, empty, over size/resolution limit, or unsupported format (png/jpeg/webp). Resize: width/height missing, or both required for Constant/InsideFixed. |
400 |
-206 |
outputFormat is not png, jpeg, jpg or webp. |
500 |
-207 |
Output could not be stored. |
500 |
-208 |
Download URL could not be created. |
401 |
-100 |
x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API. |
429 |
-221 |
Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset. |
429 |
— | Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field). |
500 |
-1 |
Unexpected server error. message is a generic error text without technical details. |
Notes
- Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).
Sample response
{
"data": {
"downloadUrl": "https://files.erseapi.com/images/sample/output.png?X-Amz-Expires=86400",
"format": "png",
"width": 800,
"height": 600,
"sizeBytes": 48210,
"expires": 1771891200
}
}
Code samples
const response = await fetch('https://api.apikodu.com/api/v1/imagegenerator/merge', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
name: 'example',
value: 123
})
});
const data = await response.json();
console.log(data);
import requests
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
}
payload = {
'name': 'example',
'value': 123
}
response = requests.post('https://api.apikodu.com/api/v1/imagegenerator/merge', headers=headers, json=payload)
data = response.json()
print(data)
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");
var payload = new { name = "example", value = 123 };
var json = JsonSerializer.Serialize(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.apikodu.com/api/v1/imagegenerator/merge", content);
response.EnsureSuccessStatusCode();
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
$data = [
'name' => 'example',
'value' => 123
];
$response = file_get_contents('https://api.apikodu.com/api/v1/imagegenerator/merge', false, stream_context_create([
'http' => [
'header' => "x-api-key: YOUR_API_KEY"
],
'method' => 'POST',"
'content' => json_encode($data)
]));
print_r(json_decode($response, true));
curl -X POST 'https://api.apikodu.com/api/v1/imagegenerator/merge' \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY' \
-d '{
"name": "example",
"value": 123
}'
Start building in minutes
Create a free account, get your API key and send your first request in minutes.