> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drssed.app/llms.txt
> Use this file to discover all available pages before exploring further.

# AI image processing: background removal and tagging

> When you upload a photo, Drssed removes the background and uses AI to detect the dominant color, garment category, seasons, and style tags.

Before you can add a clothing item to a wardrobe, you need a processed image. Drssed provides an image processing pipeline that takes a raw clothing photo, strips the background, and returns both a clean image URL and a set of AI-detected metadata — category, color, seasons, and tags — that you can use directly when creating the clothing item. This saves you from having to classify items manually and gives your users a consistent image presentation.

## POST /images/preview

This endpoint accepts a clothing photo and returns the processed result.

| Field         | Value                 |
| ------------- | --------------------- |
| Method        | `POST`                |
| Path          | `/images/preview`     |
| Auth required | Yes                   |
| Content-Type  | `multipart/form-data` |
| Rate limit    | 1 per minute          |

### Request

Send the image as a file field named `file` in a `multipart/form-data` request body.

### Response fields

**Status: 201 Created**

| Field            | Type             | Description                                                                                |
| ---------------- | ---------------- | ------------------------------------------------------------------------------------------ |
| `image_url`      | string           | URL of the processed image with the background removed.                                    |
| `image_id`       | string           | Identifier for the processed image. Pass this as `image_id` when creating a clothing item. |
| `image_color`    | string           | AI-detected dominant color of the garment (hex code or color name).                        |
| `image_category` | string           | AI-detected garment category: `JACKET`, `TOP`, `BOTTOM`, or `FOOTWEAR`.                    |
| `image_seasons`  | array of strings | AI-detected suitable seasons: any combination of `Spring`, `Summer`, `Autumn`, `Winter`.   |
| `image_tags`     | array of strings | AI-detected style tags: any combination of `Casual`, `Formal`, `Sports`, `Vintage`.        |

### Example request

```bash theme={null}
curl --request POST \
  --url https://api.drssed.com/images/preview \
  --header "Authorization: Bearer <your_access_token>" \
  --form "file=@/path/to/shirt.jpg"
```

### Example response

```json theme={null}
{
  "image_url": "https://cdn.drssed.com/processed/img_a1b2c3d4e5f6.png",
  "image_id": "img_a1b2c3d4e5f6",
  "image_color": "#3A86FF",
  "image_category": "TOP",
  "image_seasons": ["Spring", "Summer"],
  "image_tags": ["Casual"]
}
```

<Warning>
  `POST /images/preview` is rate limited to **1 request per minute** per user. Design your upload flow to process one image at a time and avoid retrying failed uploads in rapid succession.
</Warning>

<Tip>
  The response includes `image_category`, `image_seasons`, and `image_tags` detected by the AI. You can use these as default values when creating the clothing item — just pre-fill the form fields in your UI from the response and let the user adjust anything the AI got wrong.
</Tip>

## Using image\_id when creating a clothing item

The `image_id` returned by `POST /images/preview` is the value you pass in the `image_id` field when calling `POST /users/me/clothing`. Without it, you cannot create a clothing item — the field is required.

The typical flow is:

1. Call `POST /images/preview` with the photo.
2. Store the returned `image_id` (and optionally pre-fill `image_category`, `image_seasons`, `image_tags`).
3. Call `POST /users/me/clothing` with the `image_id` and any other clothing fields.

## GET /uploads/clothing\_images/{clothing_id}

Once a clothing item has been created, you can retrieve its processed image using this endpoint. Pass the `clothing_id` of the item as a path parameter.

| Field         | Value                                    |
| ------------- | ---------------------------------------- |
| Method        | `GET`                                    |
| Path          | `/uploads/clothing_images/{clothing_id}` |
| Auth required | No                                       |

The endpoint returns the processed image file directly, suitable for displaying in a wardrobe view.

## Error cases

| Status                     | Cause                                                                                                                                                                                 |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `413 Content Too Large`    | The uploaded file exceeds the maximum allowed size. Reduce the file size and try again.                                                                                               |
| `422 Unprocessable Entity` | The image could not be recognized as a garment — it may be too blurry, cropped too tightly, or contain multiple unrelated subjects. Upload a clearer photo of a single clothing item. |
