2026-06-17 17:13:31 +08:00
|
|
|
---
|
|
|
|
|
description: Extract text from images using AI-powered optical character recognition.
|
|
|
|
|
---
|
|
|
|
|
|
2026-06-08 11:52:28 +08:00
|
|
|
# OCR / Text Extraction
|
|
|
|
|
|
|
|
|
|
Extract text from images using AI-powered optical character recognition. Supports multiple languages and quality tiers.
|
|
|
|
|
|
|
|
|
|
## API Endpoint
|
|
|
|
|
|
2026-06-21 00:12:59 +08:00
|
|
|
`POST /api/v1/tools/image/ocr`
|
2026-06-08 11:52:28 +08:00
|
|
|
|
2026-07-06 08:09:22 +08:00
|
|
|
**Processing:** Synchronous JSON response. If `clientJobId` is provided, progress is also reported through SSE.
|
2026-06-08 11:52:28 +08:00
|
|
|
|
2026-07-06 08:09:22 +08:00
|
|
|
**Model bundle:** `ocr` (5-6 GB)
|
2026-06-08 11:52:28 +08:00
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
|
|
| Parameter | Type | Required | Default | Description |
|
|
|
|
|
|-----------|------|----------|---------|-------------|
|
|
|
|
|
| file | file | Yes | - | Image file (multipart) |
|
|
|
|
|
| quality | string | No | `"balanced"` | Quality tier: `fast` (Tesseract), `balanced` (PaddleOCR v5), `best` (PaddleOCR VL) |
|
|
|
|
|
| language | string | No | `"auto"` | Language hint: `auto`, `en`, `de`, `fr`, `es`, `zh`, `ja`, `ko` |
|
|
|
|
|
| enhance | boolean | No | `true` | Pre-process image for better OCR accuracy |
|
|
|
|
|
| engine | string | No | - | Deprecated. Use `quality` instead. Maps `tesseract` to `fast`, `paddleocr` to `balanced` |
|
|
|
|
|
|
|
|
|
|
## Example Request
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-06-21 00:12:59 +08:00
|
|
|
curl -X POST http://localhost:1349/api/v1/tools/image/ocr \
|
2026-06-08 11:52:28 +08:00
|
|
|
-F "file=@document.png" \
|
|
|
|
|
-F 'settings={"quality":"best","language":"en","enhance":true}'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Response (200 OK)
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
|
|
|
"filename": "document.png",
|
|
|
|
|
"text": "Extracted text content from the image...",
|
|
|
|
|
"engine": "paddleocr-vl"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Progress (SSE, optional)
|
|
|
|
|
|
2026-07-06 08:09:22 +08:00
|
|
|
If a `clientJobId` form field is provided, progress events are streamed:
|
2026-06-08 11:52:28 +08:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
event: progress
|
|
|
|
|
data: {"phase":"processing","stage":"Recognizing text...","percent":50}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
2026-07-06 08:09:22 +08:00
|
|
|
- Requires the `ocr` model bundle to be installed (5-6 GB).
|
|
|
|
|
- OCR returns extracted text directly rather than an image download URL.
|
2026-06-08 11:52:28 +08:00
|
|
|
- Uses a fallback chain: if a higher-quality tier crashes (e.g., PaddleOCR segfault), it automatically retries with the next lower tier.
|
|
|
|
|
- If a tier returns empty text without crashing, it also falls back to the next tier.
|
|
|
|
|
- Quality tiers map to engines: `fast` = Tesseract, `balanced` = PaddleOCR v5, `best` = PaddleOCR VL.
|
|
|
|
|
- Supports HEIC/HEIF, RAW, TGA, PSD, EXR, and HDR input formats via automatic decoding.
|