Files
unredact/tests/test_rasterize.py
Alex-GilbertandClaude Opus 4.6 420e20a8cf feat: PDF rasterization module
Add rasterize_pdf() that converts PDF pages to PIL images using
pdf2image. Supports configurable DPI and page range selection.
Includes tests verifying multi-page output, high-DPI dimensions,
and single-page extraction.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
2026-02-15 18:38:50 -06:00

25 lines
684 B
Python

from pathlib import Path
from PIL import Image
from unredact.pipeline.rasterize import rasterize_pdf
def test_rasterize_returns_list_of_images(sample_pdf: Path):
pages = rasterize_pdf(sample_pdf)
assert len(pages) == 2 # EFTA00554620.pdf has 2 pages
assert all(isinstance(p, Image.Image) for p in pages)
def test_rasterize_high_dpi(sample_pdf: Path):
pages = rasterize_pdf(sample_pdf, dpi=300)
# At 300 DPI, a letter-size page is roughly 2550x3300
w, h = pages[0].size
assert w > 2000
assert h > 3000
def test_rasterize_single_page(sample_pdf: Path):
pages = rasterize_pdf(sample_pdf, first_page=1, last_page=1)
assert len(pages) == 1