Smart Crop Avatar and Remove Background

Smart crop to face, remove the background, and convert to WebP for a clean user avatar.

Who this is for

Social platforms and SaaS apps use this recipe to process user-uploaded profile pictures on the fly. Smart crop centers on the face, background removal strips the messy kitchen or parking lot, and WebP conversion keeps file sizes small — ready for consistent, professional-looking avatars.

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": "upload.jpg",
      "url": "https://cdn.example.com/uploads/user-photo.jpg"
    },
    "operations": [
      {
        "type": "smart_crop",
        "width_in_px": 256,
        "height_in_px": 256
      },
      {
        "type": "remove_background"
      },
      {
        "type": "convert",
        "format": "webp",
        "quality": 85
      }
    ]
  }'
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUg...",
    "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: "upload.jpg",
    url: "https://cdn.example.com/uploads/user-photo.jpg",
  },
  operations: [
    {
      type: "smart_crop",
      width_in_px: 256,
      height_in_px: 256,
    },
    { type: "remove_background" },
    {
      type: "convert",
      format: "webp",
      quality: 85,
    },
  ],
});
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUg...",
    "mime_type": "image/webp"
  }
}
Request
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.transform(
    file={
        "type": "url",
        "name": "upload.jpg",
        "url": "https://cdn.example.com/uploads/user-photo.jpg",
    },
    operations=[
        {
            "type": "smart_crop",
            "width_in_px": 256,
            "height_in_px": 256,
        },
        {"type": "remove_background"},
        {
            "type": "convert",
            "format": "webp",
            "quality": 85,
        },
    ],
)
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUg...",
    "mime_type": "image/webp"
  }
}
Request
package main

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

func main() {
    client := il.NewClient("YOUR_API_KEY")

    result, err := client.Transform(il.TransformRequest{
        File: il.NewFileFromURL(
            "upload.jpg",
            "https://cdn.example.com/uploads/user-photo.jpg",
        ),
        Operations: []il.TransformOperation{
            il.NewSmartCropOperation(256, 256),
            il.NewRemoveBackgroundOperation(),
            il.NewConvertOperation("webp", 85),
        },
    })
    if err != nil {
        panic(err)
    }
}
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUg...",
    "mime_type": "image/webp"
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.