# Classic Editor — API

**Port:** 19002
**Base URL:** http://localhost:19002

## Operations

| Operation         | Endpoint              | Description              |
| ----------------- | --------------------- | ------------------------ |
| crop              | POST /crop            | Crop                     |
| resize            | POST /resize          | Resize                   |
| rotate            | POST /rotate          | Rotate                   |
| flip              | POST /flip            | Flip                     |
| remove_bg         | POST /remove_bg       | Remove background (rembg)|
| remove_white_bg   | POST /remove_white_bg | Remove white background  |
| convert           | POST /convert         | Change format            |
| compress          | POST /compress        | Reduce quality           |
| batch             | POST /batch           | Chain multiple operations|

## Additional endpoints

    GET /health              → Service status
    GET /operations          → List available operations

## Input

Every operation accepts an image via:

- **path** — file path
- **image** — base64 of the image

## Resize

Input:

    {
      "path": "/path/to/image.jpg",
      "width": 800,
      "height": 600,
      "maintain_aspect": true
    }

Output:

    {
      "success": true,
      "path": "/output/edit_xxx.png",
      "width": 800,
      "height": 600,
      "data": "base64..."
    }

## Crop

Input:

    {
      "path": "/path/to/image.jpg",
      "left": 0,
      "top": 0,
      "right": 500,
      "bottom": 400
    }

## Remove background

Input:

    { "path": "/path/to/image.png" }

## Batch

Input:

    {
      "path": "/path/to/image.jpg",
      "operations": [
        { "type": "resize", "width": 1024 },
        { "type": "crop", "left": 0, "top": 0, "right": 800, "bottom": 600 },
        { "type": "rotate", "angle": 90 }
      ]
    }

## CURL examples

Resize:

    curl -X POST http://localhost:19002/resize \
      -H "Content-Type: application/json" \
      -d '{"path":"/img.jpg","width":800}'

Remove background:

    curl -X POST http://localhost:19002/remove_bg \
      -H "Content-Type: application/json" \
      -d '{"path":"/img.png"}'

Batch:

    curl -X POST http://localhost:19002/batch \
      -H "Content-Type: application/json" \
      -d '{"path":"/img.jpg","operations":[{"type":"resize","width":500}]}'
