docling-project / docling-project/docling-core

feature: support ImageRefMode.NONE

Open
#364 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
282
Forks
214
Avg merge
2d 16h
Merged PRs (30d)
23

Description

Currently `ImageRefMode` only reasons about a single representation of the document https://github.com/docling-project/docling-core/blob/main/docling_core/types/doc/base.py#L9-L14 and can embed, or refernece the image - or set a placeholder.

In case of a data pipelien where the same document should be stored in different representations (raw json, plus HTML for example)

```python
document.save_as_json(
Path(f"{mypath}.json"), image_mode=ImageRefMode.REFERENCED
)
document.save_as_html(
Path(f"{mypath}.html"), image_mode=ImageRefMode.REFERENCED
)
document.save_as_markdown(
Path(f"{mypath}.md"), image_mode=ImageRefMode.REFERENCED
)
```

by setting `ImageRefMode.REFERENCED` 3x the IO is incurred - instead setting the 1st one to `REFERENCED` and others to `NONE` would save resources/ be faster:

```python
document.save_as_json(
Path(f"{mypath}.json"), image_mode=ImageRefMode.REFERENCED
)
document.save_as_html(
Path(f"{mypath}.html"), image_mode=ImageRefMode.NONE
)
document.save_as_markdown(
Path(f"{mypath}.md"), image_mode=ImageRefMode.NONE
)
```

Would this be a sensible addition?

Or possibly modifying `_with_pictures_refs` to only generate the output if it does not already exist might be an alternative solution

Contributor guide

Open the contributing guide

Research direction

Start with ImageRefMode in docling_core/types/doc/base.py, then trace save_as_json, save_as_html, save_as_markdown, and _with_pictures_refs. Compare how each serializer handles referenced images and determine the expected behavior when image_mode is NONE. Done means the three representations can be generated without repeating the referenced-image I/O.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.