You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTML, Markdown, AsciiDoc, JATS and MHTML conversions fail on CMYK, LAB and F mode pictures #4682
A picture whose color mode cannot be written as PNG aborts the whole conversion. This affects the HTML, Markdown, AsciiDoc, JATS and MHTML backends.
The modes that fail are CMYK, LAB and F. They are common in print-scanned documents and in TIFF files. A truncated or unreadable image file fails in the same way.
The shared loader docling/backend/utils/image_resource_loader.py writes each picture to PNG through ImageRef.from_pil(). Pillow cannot write these modes as PNG, so from_pil() raises OSError: cannot write mode CMYK as PNG. The except tuple in create_image_ref() does not list OSError, so the error escapes and aborts the conversion.
The Word (#4598), PowerPoint (#4586) and Excel (#4664) backends call normalize_image_for_png() before from_pil(). The shared loader does not, although five backends use it.
The observed behavior differs by backend:
Backend
Behavior
HTML, Markdown, AsciiDoc
The conversion fails with RuntimeError: Pipeline SimplePipeline failed.
JATS
The conversion reports success. The figure is dropped. All body content after the figure is lost.
MHTML
The conversion reports success. The picture is dropped silently.
The JATS case is the most severe. docling/backend/xml/jats_backend.py wraps the body walk in a bare except Exception: and logs only the traceback. One bad figure stops the body walk, so all text after the figure is lost. The caller sees a successful status.
The code in html_backend.py already states the intended behavior:
The source is not loaded, but the picture is kept, as for an image file that cannot be read.
The current behavior does not match that intent for the text backends.
Expected result: the picture is kept, or the conversion keeps the picture placeholder and emits a warning. This is the behavior that html_backend.py documents, and the behavior that the office backends already have.
Activity