Files
ChildHood/ai-art-research/tools/_build_parts_sheet.py
T
starmen1265 e8b9da5bc3 feat(ai-art): 路径C窗户字汇表(含阳台标准件修正)及首图验证
- 修正阳台标准件prompt:两扇→三对6扇+物理依据(正投影/轴测两件)
- 重生成阳台2件并核验;4标准件(卧室窗/厨卫窄窗/阳台正投影/阳台轴测)全合格
- 新增窗户字汇表(_build_parts_sheet.py 拼接3正投影件+中英标签)
- 路径C组装prompt + codex完整prompt + codex Mac指南
- 工具:_gen_standard_parts.py / _run_pathc_fuse.py
- 路径C首图(apiyi三图融合,阳台6扇一次对,风格统一无割裂)
2026-06-23 17:46:14 +08:00

92 lines
3.2 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
拼「窗户标准件合集图」(windows spec sheet) = 路径C组装prompt的【图3:窗户字汇表】。
纵向排列 3 个正投影标准件,每件下方加中英标签 + 尺度注释。
轴测件不进合集(它表达立体关系,最小闭环靠文字描述)。
需要 Pillow: pip install Pillow
"""
import sys
import io
from pathlib import Path
# Windows 控制台 UTF-8(避免 print emoji/中文时 GBK 崩溃)
if sys.platform == "win32":
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
from PIL import Image, ImageDraw, ImageFont
RESEARCH = Path(__file__).resolve().parent.parent
PARTS_DIR = RESEARCH / "生成结果" / "窗户标准件"
OUT = PARTS_DIR / "标准件合集图.png"
# (文件名, 中文, 英文, 尺度注释)
ITEMS = [
("标准件-普通窗-卧室.png", "卧室普通窗", "Bedroom window — 2-panel sliding", "约1.4m宽 · 两扇推拉 · 每扇宽高比1:2 · 把手在两端"),
("标准件-窄窗-厨卫-新版.png", "厨卫窄窗", "Kitchen/bath narrow window", "约0.7m宽 · 单扇外开 · 宽高比1:2"),
("260623-160342_gpt-image-2_gen.png", "阳台正面", "Balcony front — 6-panel sliding", "约4.2m宽 · 三对推拉共6扇 · 每扇宽高比1:2"),
]
def font(size):
for f in ["C:/Windows/Fonts/msyh.ttc", "C:/Windows/Fonts/simhei.ttf",
"C:/Windows/Fonts/arial.ttf"]:
if Path(f).exists():
try:
return ImageFont.truetype(f, size)
except Exception:
pass
return ImageFont.load_default()
ROW_H = 820
LABEL_H = 170
PAD = 50
CANVAS_W = 1700
rows = []
for fn, zh, en, note in ITEMS:
p = PARTS_DIR / fn
if not p.exists():
print(f"⚠️ 缺文件,跳过: {fn}")
continue
img = Image.open(p).convert("RGB")
w, h = img.size
scale = ROW_H / h
nw, nh = int(w * scale), ROW_H
maxw = CANVAS_W - 2 * PAD
if nw > maxw:
s2 = maxw / nw
nw, nh = int(nw * s2), int(nh * s2)
rows.append((img.resize((nw, nh), Image.LANCZOS), zh, en, note, nw))
n = len(rows)
unit = ROW_H + LABEL_H
canvas_h = unit * n + PAD * 2 + 30 * (n - 1) + 70 # +70 给顶部标题
canvas = Image.new("RGB", (CANVAS_W, canvas_h), "white")
draw = ImageDraw.Draw(canvas)
# 顶部标题:强调"尺寸仅供识别窗型,非真实比例"
draw.text((PAD, 18),
"窗户标准件字汇表 Windows Spec Sheet",
fill="black", font=font(34))
draw.text((PAD, 58),
"正投影·平涂结构图。图中窗的视觉大小仅供识别窗型,不代表真实比例;真实面宽见组装prompt的文字布局。",
fill="#666", font=font(24))
y = 100
for img2, zh, en, note, nw in rows:
x = (CANVAS_W - nw) // 2
canvas.paste(img2, (x, y))
ly = y + ROW_H + 6
draw.text((PAD, ly), zh, fill="black", font=font(46))
draw.text((PAD, ly + 58), en, fill="#555", font=font(28))
draw.text((PAD, ly + 96), note, fill="#555", font=font(26))
y += unit + 30
canvas.save(OUT)
print(f"✅ 合集图已生成: {OUT}")
print(f" 尺寸: {canvas.size}")