Two KB serving fixes on telep-mainframe. (1) The /wiring-gallery/ scanned diagrams were low-res not because of OCR but because a separate thumbnailing step downscaled the figure crops — fixed by copying the marker-native original crops verbatim (~2.5× sharper). (2) Flask app.py now sends correct Cache-Control headers (immutable for fingerprinted /_astro/*, no-cache for everything else) to stop stale-HTML / missing-image issues after redeploys. Follows the gallery pivot in 2026-07-30-kb-wiring-gallery-pivot-complete.
For Agents
- The wiring-gallery images were downscaled by
gen_thumbs.py, NOT by OCR. marker extracted the figure crops at native res;/home/levander/wiring-collection/gen_thumbs.pythen shrank them toWIDTH=320, quality=72for the gallery, and the gallery served the thumbnails.- Fix = copy the marker-native originals (the
image_abspath in/home/levander/wiring-collection/gallery_items.json) into bothmanuals-src/docs/assets/wiring-gallery/andkb-astro/public/wiring-gallery/img/. ~2.5× sharper (320 px → ~822 px).- ~822 px is the real detail ceiling — the source manual scans are only 150 dpi. Re-rendering PDF pages at 300 dpi is pointless upscaling.
build_content.pydoes NOT touch the wiring-gallery dirs — the copied originals are durable across rebuilds.
1. Wiring-gallery low-res — cause and fix
Symptom
The /wiring-gallery/ scanned diagrams were very low-res: 480 images, ~7 MB total, ~12–20 KB each.
Cause (NOT the OCR)
OCR / text extraction was fine. The pipeline was:
graph LR PDF["manual PDF<br/>(150 dpi scan)"] --> M["marker (marker-pdf / Surya OCR)<br/>native-res figure crops"] M --> T["gen_thumbs.py<br/>WIDTH=320, quality=72"] T --> G["/wiring-gallery/<br/>(served the THUMBNAILS)"] style M fill:#264653,stroke:#2a9d8f,color:#fff style T fill:#3d2020,stroke:#888,color:#fff
marker (marker-pdf / Surya OCR) extracted the figure crops at native resolution; /home/levander/wiring-collection/gen_thumbs.py downscaled them to WIDTH=320, quality=72 for the gallery, and the gallery used those thumbnails. So the loss was entirely in the thumbnailing step.
Fix
Copy the marker-native originals verbatim — their paths are in the image_abs field of /home/levander/wiring-collection/gallery_items.json — into both:
manuals-src/docs/assets/wiring-gallery/kb-astro/public/wiring-gallery/img/
Result: ~2.5× sharper (e.g. 320 px → ~822 px).
The real ceiling
~822 px is the detail ceiling — do NOT re-render at 300 dpi
The source manual scans are only 150 dpi, so ~822 px is the true detail ceiling; re-rendering the PDF pages at 300 dpi would just be upscaling with no new detail. And marker’s
*_meta.jsonhas NO per-figure bounding boxes, so you can’t re-crop the figure regions from a fresh high-DPI render without re-running marker end-to-end. If genuinely higher resolution is ever needed, that means a full marker re-run on higher-dpi page renders, not a crop-from-existing.
Durability
build_content.pydoes not touch the wiring-gallery directories, so the copied marker-native originals survive KB rebuilds — no need to re-copy after abuild_content.pyrun.
2. Astro cache-control in Flask app.py
Cache headers that stop stale-HTML / missing-image after a redeploy
Flask
app.pynow sets:
Cache-Control: immutablefor/_astro/*(Astro’s content-fingerprinted assets — safe to cache forever)no-cachefor everything else (HTML etc.)This stops the post-redeploy failure where a browser served stale HTML referencing old fingerprinted asset names (→ missing images / broken page) after an atomic
dist→~/knowledgebase/siteswap.
Related
- 2026-08-06-kb-embedding-classifiers-system-tags-and-image-types — the SigLIP zero-shot image-type classifier that later types these same gallery crops into filter pills (and finds the corpus is almost all scanned B&W line art)
- 2026-08-06-kb-build-backup-dir-leak-and-tsb-diagram-restore — a sibling image-restore case (TSB legend diagrams re-rendered from source PDFs) + the
build_content.pybackup-dir leak - 2026-07-30-kb-wiring-gallery-pivot-complete — the pivot that created
/wiring-gallery/with the 320 px thumbnails this note upgrades to marker-native crops - 2026-07-29-kb-wiring-extraction-v1-complete — where the “scan resolution is the ceiling” finding originated (stripe letters
B/RvsB/Blfail at low res) - scanned-pdf-to-markdown-marker — the marker OCR pipeline that produced the native-res crops
- 2026-08-05-power-root-cause-nvme-damage-ups-kb-handover — the KB Astro migration + atomic
dist→sitedeploy this cache-control fix supports - kb-agent-api — agent-facing KB API;
/wiring-gallery/is the authoritative wiring-scan source - cluzter — consumer of the wiring scans as calibrated tracing underlays (benefits from the sharper crops)
- telep-mainframe — the host
- homelab
- LOG
- TOPICS