POST
/api/image-resize$0.002🎨 Image Resize & Convert
Resize, crop, and convert images using Sharp. Supports output formats including JPEG, PNG, WebP, and AVIF. Great for thumbnail generation, format conversion, and image optimization pipelines.
Request Body
Response Fields
Code Examples
cURL
bash
curl -X POST https://sparkforge.sh/api/image-resize \
-H "Content-Type: application/json" \
-H "X-PAYMENT: <x402-payment-token>" \
-d '{
"url": "https://example.com/photo.jpg",
"width": 800,
"height": 600,
"format": "webp"
}'Python
python
import requests
response = requests.post(
"https://sparkforge.sh/api/image-resize",
headers={"Content-Type": "application/json", "X-PAYMENT": "<token>"},
json={"url": "https://example.com/photo.jpg", "width": 800, "format": "webp"}
)
data = response.json()
print(data["url"], data["size_bytes"])TypeScript / Node.js
typescript
const res = await fetch402("https://sparkforge.sh/api/image-resize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
url: "https://example.com/photo.jpg",
width: 800,
format: "webp",
}),
});
const { url, width, height, size_bytes } = await res.json();Example Response
json
{
"url": "https://cdn.sparkforge.sh/resized/abc123.webp",
"width": 800,
"height": 533,
"format": "webp",
"size_bytes": 45210
}💳 Payment via x402
This endpoint costs $0.002 per call, paid in USDC on Base, Polygon, or Solana. Use the @x402/fetch library to handle payments automatically, or implement the x402 handshake manually.
bash
# Free demo mode (no payment)
curl https://sparkforge.sh/api/image-resize?demo=true
# Or try via MCP (Claude Desktop, Cursor, Windsurf)
# Add to mcp config: { "url": "https://sparkforge.sh/api/mcp" }