Background
Picture pages (cover, illustrations) are currently skipped in build_html.py — they produce no HTML output. For a correct EPUB they must be embedded as <figure><img src="images/page_NNN.jpg"/> so Pandoc can include them in the EPUB container.
The cover specifically goes via --epub-cover-image in the Pandoc call, not as inline <figure>.
Plan
Write scripts/extract_images.py:
- Input: PDF path + page list (or "all picture pages" from a consensus summary.json)
- Render each page as JPEG/PNG via PyMuPDF (
fitz) at a target DPI (150–200 dpi for body illustrations; 300 dpi for cover)
- Output:
books/output/<book>/images/page_NNN.jpg
- Print a manifest of extracted images (page → path) for use by
build_html.py and the Pandoc call
Usage in the pipeline
# After consensus is run:
uv run python scripts/extract_images.py --book mindblast --pdf books/input/mindblast.pdf
# build_html.py picks up images/ directory automatically
uv run python scripts/build_html.py --book mindblast
# Pandoc uses --resource-path to find images/
pandoc book.html --resource-path books/output/mindblast/consensus/full -o mindblast.epub ...
Depends on
Required by
Acceptance criteria
Background
Picture pages (cover, illustrations) are currently skipped in
build_html.py— they produce no HTML output. For a correct EPUB they must be embedded as<figure><img src="images/page_NNN.jpg"/>so Pandoc can include them in the EPUB container.The cover specifically goes via
--epub-cover-imagein the Pandoc call, not as inline<figure>.Plan
Write
scripts/extract_images.py:fitz) at a target DPI (150–200 dpi for body illustrations; 300 dpi for cover)books/output/<book>/images/page_NNN.jpgbuild_html.pyand the Pandoc callUsage in the pipeline
Depends on
picture_page: true)Required by
<figure><img>)--epub-cover-image)Acceptance criteria
extract_images.pyproducesimages/page_NNN.jpgfor each picture page