# Face Pixelation

Pixelate faces in images to protect privacy using AI.

## Description

Upload an image and automatically detect and pixelate all human faces using Google Gemini 2.5 Flash Image (nano-banana). You can also provide a custom prompt to specify which face(s) to pixelate.

## Authentication

**Required**: x402 payment

This endpoint requires payment via the x402 protocol. See the [Setup](./setup.md) for setup instructions.

## Request

**Endpoint**: `POST /api/face-pixelation/pixelate`

**Content-Type**: `multipart/form-data`

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| image | file | Yes | Input image (JPEG, PNG, or WebP, max 10MB) |
| prompt | string | No | Custom instructions (e.g., "pixelate the face on the left") |

## Response

**200 OK**

```json
{
  "imageUrl": "/outputs/uuid-here.png"
}
```

| Field | Type | Description |
|-------|------|-------------|
| imageUrl | string | Path to the processed image with pixelated faces |

## Error Codes

| Status | Code | Description |
|--------|------|-------------|
| 400 | VALIDATION_ERROR | No image provided |
| 402 | PAYMENT_REQUIRED | x402 payment not completed |
| 413 | FILE_TOO_LARGE | File exceeds 10MB limit |
| 415 | UNSUPPORTED_FORMAT | File type not allowed (only JPEG, PNG, WebP) |
| 500 | INTERNAL_ERROR | AI generation failed |
| 504 | AI_GENERATION_TIMEOUT | AI request timed out |

## Examples

### Auto-detect and pixelate all faces

```bash
npx x402-proxy -X POST \
  -F "image=@photo.jpg" \
  https://ps.codejar.net/api/face-pixelation/pixelate
```

### Specify which face to pixelate

```bash
npx x402-proxy -X POST \
  -F "image=@group-photo.jpg" \
  -F "prompt=Pixelate the face of the person in the background" \
  https://ps.codejar.net/api/face-pixelation/pixelate
```

**Response:**
```json
{
  "imageUrl": "/outputs/550e8400-e29b-41d4-a716-446655440004.png"
}
```

## Use Cases

- **Privacy Protection**: Anonymize faces in photos before sharing
- **Journalism**: Protect identities in documentary or news images
- **Social Media**: Blur faces in user-submitted content
- **Event Photography**: Privacy-safe group photos
