16 lines
830 B
Python
16 lines
830 B
Python
"""Контрольный лист: собирает несколько скриншотов в одну картинку для быстрого просмотра."""
|
|
import sys
|
|
from pathlib import Path
|
|
from PIL import Image
|
|
img = Path(__file__).resolve().parents[2] / "docs" / "guide" / "img"
|
|
names, out, cols, w = sys.argv[3:], sys.argv[1], int(sys.argv[2]), int(sys.argv[2]) and 0
|
|
ims = [Image.open(img / f"{n}.png") for n in names]
|
|
cell = 640 if cols <= 2 else 420
|
|
th = [i.resize((cell, int(i.height * cell / i.width))) for i in ims]
|
|
rows = [th[k:k + cols] for k in range(0, len(th), cols)]
|
|
H = sum(max(t.height for t in r) for r in rows); sheet = Image.new("RGB", (cell * cols, H), "white"); y = 0
|
|
for r in rows:
|
|
for c, t in enumerate(r): sheet.paste(t, (c * cell, y))
|
|
y += max(t.height for t in r)
|
|
sheet.save(out)
|