Skip to content

fix(office): preserve CMYK pictures with ICC-aware PNG conversion - #4598

Merged
PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
iluv7:fix/cmyk-office-pictures
Oct 6, 2026
Merged

PeterStaar-IBM merged 1 commit into
docling-project:mainfrom
iluv7:fix/cmyk-office-pictures

Conversation

@iluv7

@iluv7 iluv7 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

CMYK JPEG pictures are lost during PowerPoint conversion because Pillow cannot save CMYK images as PNG. Word hits the same error and loses the image data when LibreOffice is unavailable, although conversion still reports success.

Add a shared image-mode helper before PNG serialization in both backends. Use embedded ICC profiles to convert unsupported modes to sRGB, with an RGB fallback for absent or unusable profiles. Convert PA images to RGBA to preserve per-pixel alpha, and leave PNG-compatible modes unchanged.

Validation:

  • 8 new regression tests passed, covering CMYK pictures without LibreOffice, ICC handling, and RGB/RGBA/PA pixel preservation.
  • 103 existing PowerPoint and Word backend tests passed.
  • make validate passed.
  • Local validation with a real CMYK ICC profile passed for both PPTX and DOCX without LibreOffice; output pixels matched the ICC conversion result.

Issue resolved by this Pull Request:

Resolves #4586

Checklist:

  • Documentation has been updated, if necessary. (Not required for this bug fix.)
  • Examples have been added, if necessary. (Not required for this bug fix.)
  • Tests have been added, if necessary.

Signed-off-by: guoyuchen <2273345925@qq.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @iluv7, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@PeterStaar-IBM PeterStaar-IBM left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM
PeterStaar-IBM merged commit 36cebd1 into docling-project:main Oct 6, 2026
26 checks passed
PeterStaar-IBM pushed a commit that referenced this pull request Oct 8, 2026
PNG can't store CMYK, so ImageRef.from_pil raised for a CMYK picture in an
ODT, ODP or ODS file, and _add_odf_images skipped the picture with only a
debug log. Normalize the picture first, like the Word and PowerPoint
backends do since #4598.

Resolves #4665

Signed-off-by: usmanmateen <usmanmateen255@gmail.com>
PeterStaar-IBM pushed a commit that referenced this pull request Oct 8, 2026
#4664)

Unlike the Word and PowerPoint backends since #4598, the Excel backend did
not normalize pictures before PNG serialization. A CMYK picture loaded by
openpyxl failed in ImageRef.from_pil and was dropped, and the PNG probe in
the unsupported-image scan took the same picture for an EMF/WMF image and
rendered it through LibreOffice.

Normalize the picture in both paths, so it is kept once, as stored, with or
without LibreOffice.

Resolves #4658

Signed-off-by: usmanmateen <usmanmateen255@gmail.com>
@usmanmateen usmanmateen mentioned this pull request Oct 8, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerPoint backend silently drops CMYK pictures ("cannot write mode CMYK as PNG")

2 participants