1

Ajoute les noms dans les collages globaux filtrés

This commit is contained in:
2025-12-03 23:41:12 +01:00
parent 316e1d89a7
commit f25d752e9c
3 changed files with 38 additions and 5 deletions

View File

@@ -141,15 +141,30 @@ def stack_collages(
destination_path: Path,
spacing: int = 18,
allowed_stems: Set[str] | None = None,
name_panel_width: int = 0,
labels_by_stem: Dict[str, str] | None = None,
) -> None:
"""Superpose verticalement toutes les frises présentes dans un dossier."""
images: List[Image.Image] = []
stems: List[str] = []
for path in sorted(source_dir.glob("*.png")):
if allowed_stems is not None and path.stem not in allowed_stems:
continue
images.append(Image.open(path).convert("RGB"))
stems.append(path.stem)
if not images:
return
font = ImageFont.load_default()
if name_panel_width > 0:
with_names: List[Image.Image] = []
for image, stem in zip(images, stems):
label = labels_by_stem.get(stem, stem) if labels_by_stem else stem
name_img = render_label(name_panel_width, image.height, label, font).convert("RGB")
combined = Image.new("RGB", (name_panel_width + image.width, image.height), (255, 255, 255))
combined.paste(name_img, (0, 0))
combined.paste(image, (name_panel_width, 0))
with_names.append(combined)
images = with_names
max_width = max(image.width for image in images)
total_height = sum(image.height for image in images) + spacing * (len(images) - 1)
canvas = Image.new("RGB", (max_width, total_height), (255, 255, 255))