代码提交
This commit is contained in:
1 parent
49af497085
commit
3eb307c5c5
155 files changed
+4706
-100
No files matched your search
@@ -0,0 +1,33 @@
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parent
|
||||
PAGES = ROOT / "rendered" / "pages"
|
||||
OUT = ROOT / "rendered" / "contact-sheets"
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
font_path = Path(r"C:\Windows\Fonts\arialbd.ttf")
|
||||
font = ImageFont.truetype(str(font_path), 28)
|
||||
page_paths = sorted(PAGES.glob("page-*.png"))
|
||||
|
||||
for sheet_index in range(0, len(page_paths), 4):
|
||||
group = page_paths[sheet_index : sheet_index + 4]
|
||||
images = [Image.open(p).convert("RGB") for p in group]
|
||||
page_w, page_h = images[0].size
|
||||
gutter = 48
|
||||
label_h = 52
|
||||
sheet = Image.new("RGB", (page_w * 2 + gutter * 3, (page_h + label_h) * 2 + gutter * 3), "#D7DEE5")
|
||||
draw = ImageDraw.Draw(sheet)
|
||||
for i, (path, img) in enumerate(zip(group, images)):
|
||||
col, row = i % 2, i // 2
|
||||
x = gutter + col * (page_w + gutter)
|
||||
y = gutter + row * (page_h + label_h + gutter)
|
||||
draw.text((x, y), path.stem, font=font, fill="#172A3A")
|
||||
sheet.paste(img, (x, y + label_h))
|
||||
first = sheet_index + 1
|
||||
last = sheet_index + len(group)
|
||||
sheet.save(OUT / f"pages-{first:02d}-{last:02d}.jpg", quality=92, subsampling=0)
|
||||
|
||||
print(f"created {len(list(OUT.glob('*.jpg')))} contact sheets")
|
||||
Reference in new issue
Block a user