docling icon indicating copy to clipboard operation
docling copied to clipboard

OpenDocument backends drop CMYK pictures

Open usmanmateen opened this issue 1 month ago • 0 comments

Bug

A CMYK picture in an ODT, ODP or ODS file is dropped. The conversion still reports SUCCESS, and the only trace is a debug log (Could not extract OpenDocument image). The same picture in RGB is kept.

It's the same problem as #4586 (Word and PowerPoint, fixed with normalize_image_for_png in #4598) and #4658 (Excel): PNG can't store CMYK, so ImageRef.from_pil raises. _image_ref_from_odf_image passes the picture to ImageRef.from_pil without normalizing it, and _add_odf_images catches the error and skips the picture.

Steps to reproduce

from odfdo import Document, Frame, Paragraph
from PIL import Image

from docling.document_converter import DocumentConverter

Image.new("CMYK", (200, 100), (0, 255, 255, 0)).save("cmyk.jpg", format="JPEG")

doc = Document("text")
doc.body.clear()
paragraph = Paragraph("")
paragraph.append(Frame.image_frame(doc.add_file("cmyk.jpg"), size=("2cm", "1cm")))
doc.body.append(paragraph)
doc.save("cmyk.odt")

result = DocumentConverter().convert("cmyk.odt")
print(result.status, len(result.document.pictures))  # ConversionStatus.SUCCESS 0

With an RGB picture instead (Image.new("RGB", (200, 100), "red")), it prints ConversionStatus.SUCCESS 1. ODP (a frame on a draw page) and ODS (a picture in a cell) behave the same way.

Docling version

main at 213288f (the code is the same in 2.135.0)

Python version

Python 3.12.13

I have a fix with tests and will open a PR.

usmanmateen avatar Oct 08 '26 01:10 usmanmateen