Convert Image Format

Convert an image between PNG, JPEG, and WebP formats with quality control for web optimization.

Who this is for

Web development teams and CDN operators use this recipe to convert an image to a modern format like WebP for faster page loads. Upload an image and convert it to your target format with precise quality control — ready for optimized delivery.

Request
curl -X POST https://api.iterationlayer.com/image-transformation/v1/transform \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file": {
      "type": "url",
      "name": "image.png",
      "url": "https://example.com/image.png"
    },
    "operations": [
      { "type": "convert", "format": "webp", "quality": 85 }
    ]
  }'
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/webp"
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const result = await client.transform({
  file: {
    type: "url",
    name: "image.png",
    url: "https://example.com/image.png",
  },
  operations: [
    { type: "convert", format: "webp", quality: 85 },
  ],
});

const imageBuffer = Buffer.from(result.data.buffer, "base64");
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/webp"
  }
}
Request
import base64

from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.transform(
    file={
        "type": "url",
        "name": "image.png",
        "url": "https://example.com/image.png",
    },
    operations=[
        {"type": "convert", "format": "webp", "quality": 85},
    ],
)

with open("result.webp", "wb") as f:
    f.write(base64.b64decode(result["data"]["buffer"]))
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/webp"
  }
}
Request
package main

import il "github.com/iterationlayer/sdk-go"

client := il.NewClient("YOUR_API_KEY")

result, err := client.Transform(il.TransformRequest{
    File:       il.NewFileFromURL("image.png", "https://example.com/image.png"),
    Operations: []il.TransformOperation{il.NewConvertOperation("webp")},
})
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/webp"
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.