Convert format
POST
https://api.imagemcpserver.com/playground/convert-format💳 1 credit🛠️ MCP tool: convert_format⌘ imagemcp.js convert
A straight format conversion with no model in the loop. Reach for it when a downstream tool only accepts one format, or when you want PNG screenshots delivered as WebP.
Overview
Convert an image between PNG, JPEG, WebP and other common formats.
Flat 1 credit per call.
Request
Headers
| Field | Type | Description |
|---|---|---|
Authorizationrequired | string | Bearer <IMAGEMCP_API_KEY>. The header x-api-key: <key> is accepted as an alternative. |
Content-Typerequired | string | application/json |
Body parameters
| Field | Type | Description |
|---|---|---|
imagerequired | string | Input image as an https URL or a base64 data URI. imageBase64 is accepted as an alias for the same value. |
targetFormat | string | Output format — png, jpeg/jpg, webp, gif, bmp. Defaults to "png". |
Examples
The same call in five forms. The MCP tab is what an MCP client sends under the hood; the CLI tab is what an agent with the agent skill runs.
convert_format
curl -X POST "https://api.imagemcpserver.com/playground/convert-format" \
-H "Authorization: Bearer $IMAGEMCP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://example.com/photo.png",
"targetFormat": "webp"
}'imagemcp.js convert --image ./photo.png --format webp --out ./photo.webpconst res = await fetch("https://api.imagemcpserver.com/playground/convert-format", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"image": "https://example.com/photo.png",
"targetFormat": "webp"
}),
});
const data = await res.json();
console.log(data.result.imageUrl);import os
import requests
res = requests.post(
"https://api.imagemcpserver.com/playground/convert-format",
headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
json={
"image": "https://example.com/photo.png",
"targetFormat": "webp"
},
timeout=120,
)
print(res.json()){
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "convert_format",
"arguments": {
"image": "https://example.com/photo.png",
"targetFormat": "webp"
}
}
}Response
Response fields
| Field | Type | Description |
|---|---|---|
result.imageUrl | string | Converted image (data URI). |
result.originalFormat | string | Format detected on the input. |
result.targetFormat | string | Format written. |
result.mimeType | string | MIME type of the output. |
{
"success": true,
"message": "Image converted to WEBP successfully",
"deductedCredits": 1,
"userCredits": 2417,
"result": {
"imageUrl": "data:image/webp;base64,UklGRl4…",
"originalFormat": "PNG",
"targetFormat": "WEBP",
"mimeType": "image/webp",
"latency": "0.31s",
"cost": "$0.0000",
"deductedCredits": 1,
"userCredits": 2417
}
}When it fails
Errors return
success: false with a message. See errors & troubleshooting for the status codes and whether a retry is worth it.FAQ
How is this different from compress_image?
convert_format changes the container without a quality setting; compress_image re-encodes at a quality you choose and reports how much size was saved. Use compress when the goal is a smaller file.