You've already forked etude_lego_jurassic_world
Filtre les collages globaux sur les personnages multi-variations
This commit is contained in:
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from lib.plots.minifig_character_collages import build_character_collages
|
||||
from lib.plots.minifig_character_collages import build_character_collages, stack_collages
|
||||
from lib.rebrickable.minifig_character_sets import build_character_sets, group_by_character
|
||||
from lib.rebrickable.resources import sanitize_name
|
||||
|
||||
@@ -114,7 +114,7 @@ def test_build_character_sets_and_collages(tmp_path: Path) -> None:
|
||||
head_image = resources_dir / "1000" / sanitize_name("Alice") / "head.jpg"
|
||||
create_image(head_image, (10, 120, 60), (8, 12))
|
||||
head_collages = build_character_collages(
|
||||
group_by_character(character_sets),
|
||||
{"Bob": group_by_character(character_sets)["Bob"]},
|
||||
resources_dir,
|
||||
heads_destination,
|
||||
missing_paths=head_missing,
|
||||
@@ -123,8 +123,23 @@ def test_build_character_sets_and_collages(tmp_path: Path) -> None:
|
||||
label_height=8,
|
||||
spacing=2,
|
||||
)
|
||||
assert len(head_collages) == 3
|
||||
alice_head = Image.open(heads_destination / f"{sanitize_name('Alice')}.png")
|
||||
assert len(head_collages) == 1
|
||||
bob_head = Image.open(heads_destination / f"{sanitize_name('Bob')}.png")
|
||||
assert alice_head.size[1] == 24
|
||||
assert bob_head.getpixel((3, 8)) == (220, 220, 220)
|
||||
|
||||
|
||||
def test_stack_collages_with_filter(tmp_path: Path) -> None:
|
||||
"""Assemble une grille verticale en filtrant les frises autorisées."""
|
||||
source_dir = tmp_path / "collages"
|
||||
source_dir.mkdir()
|
||||
img1 = source_dir / "Alice.png"
|
||||
img2 = source_dir / "Bob.png"
|
||||
Image.new("RGB", (10, 6), (100, 100, 100)).save(img1)
|
||||
Image.new("RGB", (14, 8), (120, 120, 120)).save(img2)
|
||||
|
||||
destination = tmp_path / "stacked.png"
|
||||
stack_collages(source_dir, destination, spacing=2, allowed_stems={"Bob"})
|
||||
|
||||
result = Image.open(destination)
|
||||
assert result.size == (14, 8)
|
||||
assert result.getpixel((0, 0)) == (120, 120, 120)
|
||||
|
||||
Reference in New Issue
Block a user