docling-project / docling-project/docling

[Bee] Support for Truncated Img Files and Reading Order Improvement

Open
#3,723 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Requested feature

1. Support for truncated/corrupted JPEG image files

Docling currently fails with an error when attempting to convert truncated image files (files where the image data is incomplete or partially corrupted). These files are valid enough to be rendered and processed by tools that use PIL's LOAD_TRUNCATED_IMAGES flag, but Docling's image loading pipeline does not account for this case.

The requested feature is for Docling to gracefully handle truncated image files by enabling PIL's ImageFile.LOAD_TRUNCATED_IMAGES = True (or an equivalent fallback strategy) so that conversion can proceed rather than failing outright. This mirrors what many production pipelines already do and would allow Docling to return a best-effort result instead of an error.

Sample truncated img file 1: [https://ibm.box.com/s/gmie28q7no5flf0gdcb88k04auskye0e](https://ibm.box.com/s/gmie28q7no5flf0gdcb88k04auskye0e)
Sample truncated img file 2: [https://ibm.box.com/s/76ok5w6soyxagwdwf56cbu755xtneruc](https://ibm.box.com/s/76ok5w6soyxagwdwf56cbu755xtneruc)

2. Reading order improvement for mixed handwritten + machine-printed documents with rotation

When processing the JPG image file that contains both handwritten and machine-printed text with slight rotational skew (even when autorotation_correction=True is set), the reading order of the output is incorrect. Specifically, sentences that span both handwritten and machine-printed segments have their words interleaved out of sequence. We are processing this file with Docling + custom OCR.

Incorrect output: [https://ibm.box.com/s/d26efi48coq4ffoxoekp7s7sciup9ve8](https://ibm.box.com/s/d26efi48coq4ffoxoekp7s7sciup9ve8)

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by locating Docling’s Python image-loading pipeline and the reading-order path used with autorotation_correction=True; reproduce both cases with the linked truncated JPEGs and mixed handwritten/printed JPG. Done means truncated images convert without failing and the mixed-content output preserves sentence order, with regression coverage for both behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.