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 commit 130a10e2d9.

* 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: 420df478f3
I, copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>, hereby add my Signed-off-by to this commit: c1d722725f
I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: 6aa85cc933
I, copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 130a10e2d9
I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: d571f36299
I, Christoph Auer <cau@zurich.ibm.com>, hereby add my Signed-off-by to this commit: 2aab66288b

Signed-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:
Copilot
2025-07-23 09:55:40 +02:00
committed by GitHub
parent ec971bbe68
commit 8d50a59d48
3 changed files with 48 additions and 1 deletions

BIN
tests/data/tiff/2206.01062.tif vendored Normal file

Binary file not shown.

View File

@@ -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