diff --git a/src/scalper/typeset.py b/src/scalper/typeset.py index f74fc10..c5ca288 100644 --- a/src/scalper/typeset.py +++ b/src/scalper/typeset.py @@ -5,6 +5,7 @@ de la traduction (Pillow uniquement). from __future__ import annotations import json +import shutil from pathlib import Path from typing import Any @@ -159,4 +160,12 @@ def typeset_chapter(chapter_dir: Path, lang: str, ocr_file: str = "ocr.json", tr src = images_dir / name if src.exists(): outputs.append(str(replace_texts(src, regions, translations, out_dir / name))) + # pages sans texte détecté : copiées telles quelles pour un export complet + for p in sorted(images_dir.iterdir()): + if p.is_file() and p.suffix.lower() in (".png", ".jpg", ".jpeg", ".webp") and p.name not in by_image: + out = out_dir / p.name + if not out.exists(): + out_dir.mkdir(parents=True, exist_ok=True) + shutil.copyfile(p, out) + outputs.append(str(out)) return outputs diff --git a/tests/test_ocr_typeset.py b/tests/test_ocr_typeset.py index 68647b9..71daf75 100644 --- a/tests/test_ocr_typeset.py +++ b/tests/test_ocr_typeset.py @@ -199,9 +199,11 @@ class TestOCRTypeset(unittest.TestCase): json.dumps({"lang": "eng", "regions": [{"index": 0, "image": "p1.png", "box": [10, 10, 280, 60], "text": "Hello world"}]}), encoding="utf-8", ) + self._make_image(d / "images" / "p2.png", size=(200, 100)) # sans région OCR outputs = typeset_chapter(d, "fr", translations=["Bonjour le monde"]) - self.assertEqual(len(outputs), 1) + self.assertEqual(len(outputs), 2) self.assertTrue((d / "export" / "images-fr" / "p1.png").exists()) + self.assertTrue((d / "export" / "images-fr" / "p2.png").exists(), "page sans texte copiée telle quelle") def test_inpaint_uses_background_ring_not_text(self): img = Image.new("RGB", (300, 120), (200, 220, 255))