mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-08 20:58:11 +00:00
fix: multi-page image support (tiff) (#1928)
* Initial plan * Fix multi-page TIFF image support Co-authored-by: cau-git <60343111+cau-git@users.noreply.github.com> * add RGB conversion Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * Remove pointless test Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * Add multi-page TIFF test data and verification tests Co-authored-by: cau-git <60343111+cau-git@users.noreply.github.com> * Revert "Add multi-page TIFF test data and verification tests" This reverts commit130a10e2d9. * Proper test for 2 page tiff file Signed-off-by: Christoph Auer <cau@zurich.ibm.com> * DCO Remediation Commit for copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> I, copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>, hereby add my Signed-off-by to this commit:420df478f3I, copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>, hereby add my Signed-off-by to this commit:c1d722725fI, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit:6aa85cc933I, copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>, hereby add my Signed-off-by to this commit:130a10e2d9I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit:d571f36299I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit:2aab66288bSigned-off-by: Christoph Auer <cau@zurich.ibm.com> * Proper test for 2 page tiff file (2) Signed-off-by: Christoph Auer <cau@zurich.ibm.com> --------- Signed-off-by: Christoph Auer <cau@zurich.ibm.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cau-git <60343111+cau-git@users.noreply.github.com> Co-authored-by: Christoph Auer <cau@zurich.ibm.com>
This commit is contained in:
BIN
tests/data/tiff/2206.01062.tif
vendored
Normal file
BIN
tests/data/tiff/2206.01062.tif
vendored
Normal file
Binary file not shown.
@@ -243,3 +243,26 @@ def _make_input_doc_from_stream(doc_stream):
|
||||
backend=PdfFormatOption().backend, # use default
|
||||
)
|
||||
return in_doc
|
||||
|
||||
|
||||
def test_tiff_two_pages():
|
||||
tiff_path = Path("./tests/data/tiff/2206.01062.tif")
|
||||
doc = InputDocument(
|
||||
path_or_stream=tiff_path,
|
||||
format=InputFormat.IMAGE,
|
||||
backend=PdfFormatOption().backend, # use default backend
|
||||
)
|
||||
assert doc.valid is True
|
||||
assert doc.page_count == 2
|
||||
|
||||
# Expect two full-page rectangles
|
||||
rects_page1 = doc._backend.load_page(0).get_bitmap_rects()
|
||||
rects_page2 = doc._backend.load_page(1).get_bitmap_rects()
|
||||
|
||||
page1_rect = next(rects_page1)
|
||||
page2_rect = next(rects_page2)
|
||||
|
||||
assert page1_rect.t == page2_rect.t == 0
|
||||
assert page1_rect.l == page2_rect.l == 0
|
||||
assert page1_rect.r == page2_rect.r == 612.0
|
||||
assert page1_rect.b == page2_rect.b == 792.0
|
||||
|
||||
Reference in New Issue
Block a user