Skip to content

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

Description

@SanjanaNagwekar

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
Sample truncated img file 2: https://ibm.box.com/s/76ok5w6soyxagwdwf56cbu755xtneruc

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions