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

# Rich-text OCR (text-layer content and styles)

> During layer decomposition, also return the text, line-by-line positions and approximate styles (font, color, bold…) of regular text layers.

During layer decomposition, Seedream 5.5 can return rich-text OCR results for **regular text layers**: the text, the position of each line and approximate visual styles. Design tools and applications can combine this data with the decomposed layers to change copy, localize content and reuse templates. Editing the text and compositing the layers is done by your tool or application.

![Seedream 5.5 decomposition returns a base image, independent layers, and OCR results for regular text so applications can edit text](https://arkdocs-en.tos-ap-southeast-1.volces.com/flowcharts/image-generation/seedream-5-5-ocr-workflow-overview.svg)

[Watch the demo video](https://arkdocs-en.tos-ap-southeast-1.volces.com/videos/image-generation/seedream-5-5-ocr-demo-en.mp4)

## Example

The example decomposes a poster and obtains the OCR results of its text layers. The request sets `max_images: 15` and returns 13 images: one base image and 12 layers, nine of which are text layers with OCR results.

| Input | Text layer | OCR result |
| - | - | - |
| ![Poster to decompose and recognize](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test2.png) | ![Text layer containing Presented By and a name](https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/seedream-5-5-ocr-regular-text-layer-20261103.png) | **Text**: line 1 `Presented By :`, line 2 `Anna Katrina Marchesi` **Position (absolute pixel coordinates)**: line 1 `[1196, 629, 1358, 658]`, line 2 `[1195, 651, 1427, 681]` **Similar font**: Helvetica Neue for both lines **Color**: line 1 `#193366`, line 2 `#46597E` **Bold**: line 1 `true`, line 2 `false` |

> [!TIP]
>
> Download the official [full example package (ZIP, about 6.7 MB)](https://arkdocs-en.tos-ap-southeast-1.volces.com/files/image-generation/seedream-5-5-ocr-interactive-example-20261104-v4.zip) with the input poster, the base image, all layers, the OCR data and an interactive page: extract it keeping the directory structure, open `seedream-55-ocr-preview.html` in a browser and select a text layer to inspect the text, coordinates and styles of each line and preview changes to the text, colors and bold styling.

## Enable OCR

In a layer decomposition request, set both:

* `layer_decomposition: true` to enable layer decomposition;
* `layer_decomposition_options.text_recognition: true` to request OCR results for regular text layers.

```bash cURL theme={null}
curl -X POST "https://api.dreamto.ai/api/v3/images/generations" \
  -H "Authorization: Bearer $DREAMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedream-5.5",
    "prompt": "Decompose the elements in the image into independent layers.",
    "image": "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test2.png",
    "size": "auto",
    "layer_decomposition": true,
    "layer_decomposition_options": {
      "max_images": 15,
      "text_recognition": true
    },
    "output_format": "png",
    "response_format": "url",
    "watermark": true
  }'
```

```python Python theme={null}
import os

import requests

URL = "https://api.dreamto.ai/api/v3/images/generations"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "model": "seedream-5.5",
    "prompt": "Decompose the elements in the image into independent layers.",
    "image": "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test2.png",
    "size": "auto",
    "layer_decomposition": True,
    "layer_decomposition_options": {
        "max_images": 15,
        "text_recognition": True
    },
    "output_format": "png",
    "response_format": "url",
    "watermark": True
}

result = requests.post(URL, headers=HEADERS, json=payload, timeout=600).json()
for image in result["data"]:
    print(image["url"])
```

```python OpenAI SDK theme={null}
import os

from openai import OpenAI

client = OpenAI(base_url="https://api.dreamto.ai/api/v3", api_key=os.environ["DREAMTO_API_KEY"])

response = client.images.generate(
    model="seedream-5.5",
    prompt="Decompose the elements in the image into independent layers.",
    size="auto",
    output_format="png",
    response_format="url",
    extra_body={
        "image": "https://arkdocs-en.tos-ap-southeast-1.volces.com/images/image-generation/ocr-test2.png",
        "layer_decomposition": True,
        "layer_decomposition_options": {
            "max_images": 15,
            "text_recognition": True
        },
        "watermark": True,
    },
)
for item in response.data:
    print(item)
```

## OCR response fields

The OCR result of a text layer is returned in `data[].text_recognition`: the complete plain text, plus positions, text and styles organized by text lines and style runs.

| Field | Description |
| - | - |
| `text_recognition` | Rich-text OCR result of the current text layer. |
| `text_recognition.text` | The complete plain text, top to bottom and left to right, with lines separated by `\n`. |
| `text_recognition.lines[]` | The text lines in order; each line has a position and style runs. |
| `lines[].bounding_box` | Bounding box of the line in the coordinate system of the output base image, with `absolute` and `normalized` coordinates, for restoring the text to its place on the base image or a target canvas. |
| `bounding_box.absolute` | Absolute pixel coordinates `[left, top, right, bottom]` of the box; the top-left of the output base image is `(0, 0)`. |
| `bounding_box.normalized` | Integer coordinates `[left, top, right, bottom]` scaled to 0–1000 from the output base image size, for computing the position of the line on a target canvas. |
| `lines[].runs[]` | Style runs of the line; each run has one style. A line with uniform styling has one run; changes of font, color, weight and so on within the line give several. |
| `runs[].text` | Text of the run, without line breaks. |
| `runs[].style` | Approximate visual style of the run, with the eight fields below. The model recognizes styles automatically, so they may differ from the exact attributes of the original design file. |
| `style.similar_font_family` | Name of the closest font matched from the appearance; `unknown` when it cannot be recognized or confidence is insufficient. |
| `style.foreground_color` | Text color in uppercase `#RRGGBB`, without an alpha channel. |
| `style.bold` | Whether the model recognized bold text. |
| `style.italic` | Whether the model recognized italic text: `true` only when the glyphs themselves slant right; rotation or perspective skew does not count. |
| `style.underline` | Whether the model recognized an underline; a separate divider, table rule or decorative line does not count. |
| `style.strikethrough` | Whether the model recognized strikethrough text. |
| `style.shadow` | Whether the model recognized a visible drop shadow, shadow or glow offset; a regular antialiasing transition does not count. |
| `style.translucent` | Whether the text itself is visibly translucent and reveals the background texture or color; solid light-gray or light-blue text does not count. |

### Text-layer response example

The `data[]` item of the text layer containing `Presented By :` and `Anna Katrina Marchesi` in the example above (`z_index: 6`).

```json theme={null}
{
  "url": "https://files.dreamto.ai/images/seedream_layer_6_9b21.png",
  "size": "1166x899",
  "output_format": "png",
  "background": "transparent",
  "z_index": 6,
  "name": "Presenter text",
  "description": "Two lines of dark blue presenter text",
  "bounding_box": {
    "absolute": [
      1142,
      528,
      1474,
      784
    ],
    "normalized": [
      643,
      529,
      830,
      786
    ]
  },
  "text_recognition": {
    "text": "Presented By : \nAnna Katrina Marchesi",
    "lines": [
      {
        "bounding_box": {
          "absolute": [
            1196,
            629,
            1358,
            658
          ],
          "normalized": [
            673,
            630,
            765,
            659
          ]
        },
        "runs": [
          {
            "text": "Presented By : ",
            "style": {
              "similar_font_family": "Helvetica Neue",
              "foreground_color": "#193366",
              "bold": true,
              "italic": false,
              "underline": false,
              "strikethrough": false,
              "shadow": false,
              "translucent": false
            }
          }
        ]
      },
      {
        "bounding_box": {
          "absolute": [
            1195,
            651,
            1427,
            681
          ],
          "normalized": [
            673,
            652,
            803,
            682
          ]
        },
        "runs": [
          {
            "text": "Anna Katrina Marchesi",
            "style": {
              "similar_font_family": "Helvetica Neue",
              "foreground_color": "#46597E",
              "bold": false,
              "italic": false,
              "underline": false,
              "strikethrough": false,
              "shadow": false,
              "translucent": false
            }
          }
        ]
      }
    ]
  }
}
```

## Limitations

* **Recognition coverage**: only regular text layers return OCR results; see [OCR supported fonts](https://docs.dreamto.ai/en/image/models/seedream-5-5/ocr-supported-fonts.md) for the fonts that can be recognized. Base images, non-text layers, artistic text and handwritten text do not return `text_recognition`.
* **Font recognition**: `similar_font_family` is an approximate match and is not guaranteed to equal the original font. It returns `unknown` when recognition is unavailable or confidence is insufficient.
* **Style recognition**: style information is approximate; `false` means the model did not recognize the style.
* OCR does not change billing: the request is still billed by the images returned; see [Fine-grained layer decomposition](https://docs.dreamto.ai/en/image/models/seedream-5-5/layer-decomposition.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.