# StampSign.kr API Capabilities (AEO skill.md)

This specification outlines the programmatic interface and digital image manipulation capabilities of **stampsign.kr** for AI Coding Agents.

---

## 1. Capabilities (What I can accomplish)
- **Background Erasure**: 
  - **Light backgrounds**: Automatically erases white/grey scanner margins and paper colors from stamps or signatures.
  - **Dark backgrounds**: Erases 어두운/다크모드 backgrounds and outputs cleanly inverted transparent foreground files.
- **Color Manipulation**: 
  - Overwrites existing stamp/signature colors with solid Hex values (e.g. Red `#c80000`, Blue `#0000ff`, Black `#000000`) dynamically while preserving transparency and antialiased edges.
- **Sharpness Correction**: 
  - Compensates for blurry images by applying customizable gamma/density scales (values from `0.1` to `3.0`).
- **Overlap Layer Separation**:
  - **Stamp Extraction**: Separates colored seals/stamps from black text overlay.
  - **Text Extraction**: Separates black signatures/text from colored seals/stamps.

---

## 2. API Signature & Execution Protocol

### Endpoint: `POST /api/process-stamp`
Processes a raw pixel buffer and performs high-precision edge transparency, coloring, and sharpness processing.

### Required HTTP Headers
- `Content-Type`: `application/octet-stream`
- `X-Width`: Width of the raw image canvas (string integer).
- `X-Height`: Height of the raw image canvas (string integer).
- `X-Color`: Hex color code for color replacement (regex: `/^#[0-9a-fA-F]{6}$/`, default: `#c80000`).
- `X-Sharpness`: Target density scale factor (float string from `0.1` to `3.0`, default: `1.0`).
- `X-Bg-Type`: Background type indicator (`light` | `dark` | `overlap`).
- `X-Overlap-Extract`: Required if `X-Bg-Type` is `overlap` (`stamp` | `text`).

### Request Body
Raw RGBA pixel byte array (`width * height * 4` bytes, standard 8-bit `Uint8Array`).

### Response Headers
- `Content-Type`: `application/octet-stream`
- `X-Original-Width`: Width of original image sent.
- `X-Original-Height`: Height of original image sent.
- `X-Width`: Crop boundary box width calculated by edge detection.
- `X-Height`: Crop boundary box height calculated by edge detection.
- `X-Crop-X`: Crop boundary box X offset coordinate.
- `X-Crop-Y`: Crop boundary box Y offset coordinate.

---

## 4. Constraints & Rate Limits
- **Upload File Limits**: 20MB (`MAX_FILE_SIZE`).
- **Canvas Resolution Max bounds**: 8000×8000 pixels.
- **Server Rate Limiter**: 100 requests per IP per minute.
- **Client Fallback**: Active in <15ms offline whenever fetch results are pending.
