Peach: Local-first video metadata scraper and media manager.
fix: 厂牌标识摆进圆形图位不再发空或被切角
longmeidao5d35450125c1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f837df71b..6f0aca618 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -53,6 +53,10 @@ Removed / Fixed / Security。### 修复- **采集**:矢量的厂牌标识也能归一成带边距的方图,仍然是矢量;白字标配深底,不会在浅底上看不见。+- **采集**:厂牌标识在圆形图位里摆得端正:自带大留白的裁掉多余空白,顶到边的补足四周,标识的四角+ 不再被圆形切掉。像素不缩放,清晰度不变。+- **采集**:浅色笔画的位图标识同样配深底;自带整块底的标识保持原样。已装的标识重跑归一时从备份原图+ 开始,算法的改进也能落到它们身上。- **配置**:桌面快捷方式创建或移除失败时报出真实原因,而不是只说失败。- **界面**:危险操作(移除媒体文件夹等)统一走同一个二次确认。- **界面**:忙态提示会说明正在进行的动作;禁用的开关与按钮给出正确的颜色和光标。diff --git a/docs/PRODUCT_BACKLOG.md b/docs/PRODUCT_BACKLOG.mdindex 4d748798a..a38e0569e 100644--- a/docs/PRODUCT_BACKLOG.md+++ b/docs/PRODUCT_BACKLOG.md@@ -96,7 +96,7 @@18. 另行授权后跑 `scripts/normalize_link_hosts.py --apply --backup <落点>`,把 296 条 twitter 写法收成 x.com(290 改写、6 删除),随后重启托盘并在真实浏览器验收 `/link-mark` 的清晰度与边缘。19. 用户复核 `directory-links-<日期>.csv` 后用 `install_entity_links.py` 装入社媒链接;`conflict` 且账本旧号「疑似失效」的行由用户决定换号,随后可对账本现有全部 X 链接跑同样的验活。20. 用户复核 `studio-names-<日期>.csv` 的 26 条厂牌改名后另行授权;3 条不一致按「一个账本名混了两家」处理,5 条 404 未取得,搜索兜底要先有一个能用的搜索出口。-21. 厂牌标识规则:logo 文件一律不透明方图(位图 `images.bake_square`、矢量 `images.bake_square_vector`),页面三处一律 cover。位图那批已经回溯完(26 烤白底、5 补方);另行授权后再跑一次 `normalize_studio_logos.py --apply --backup <落点>`,2026-09-07 dry-run 还剩 4 张 SVG 待包方底:DarkRoomVR、TeamSkeetXReislin、TeenFidelity、VirtualTaboo,其中前两张是白字标、按实测配深底。+21. 厂牌标识规则:logo 文件一律不透明方图(位图 `images.bake_square`、矢量 `images.bake_square_vector`),产物再过 `images.refit_plate` 摆到圆形图位里看得全的位置,页面三处一律 cover。另行授权后跑一次 `normalize_studio_logos.py --apply --backup <落点>`,2026-09-08 dry-run 报 52 张待改:46 张重新摆位(自带大留白的裁掉、顶到边的补到外接圆)、4 张 SVG 包方底(DarkRoomVR、TeamSkeetXReislin、TeenFidelity、VirtualTaboo,前两张白字标配深底)、HEYZO 从备份原图重烤改配深底、pikpak 重补方。22. 把 javdatabase 的 idol 页接进社媒/官网候选:183 页缓存里 139 页带 X 链接、138 页带另一个官方站,由番号定位、不必离线比名。复用 `peach.social_links` 的判据与 `install_entity_links.py` 的 `FIELDS`,排掉四个整站广告主机。23. 人工判 `domain-code-review.csv` 里 `WX17` 那 269 条水印存疑行,脚本不给提案。24. 给账本厂牌补日文别名。MGStage 名录 351 家只对上 29 家,卡点是账本 118 个厂牌只有 27 条别名、几乎没有日文名——补完别名再对一次,覆盖面会一次性抬上去。diff --git a/docs/SOURCING.md b/docs/SOURCING.mdindex baabf20d4..9e612fdae 100644--- a/docs/SOURCING.md+++ b/docs/SOURCING.md@@ -519,10 +519,19 @@ Windows 空数据预览的项目 CA HTTPS、合成 Cookie 保存/撤销、DMM原尺寸居中、四周用同一张图放大模糊补底(页面侧的 `data-fit-native`)。边距和底色烤进文件,页面不再各自补救。位图的唯一入口是 `peach.images.bake_square`,`classify_plate` 给出它据以分流的判定:- - `mark`(有透明像素,如 PREMIUM 的全透明底蓝色字标)——按 alpha 外接框裁掉透明边,居中放到**白色- 不透明**方底上,内容占边长 `PLATE_CONTENT_RATIO`(0.76,四周各留约 12%),像素不缩放,出不透明 PNG。+ - `mark`(有透明像素,如 PREMIUM 的全透明底蓝色字标)——按 alpha 外接框裁掉透明边,居中放到不透明+ 方底上,内容占边长 `PLATE_CONTENT_RATIO`(0.76,四周各留约 12%),像素不缩放,出不透明 PNG。- `tile`(完全不透明,如 M's Video Group 400×400 黑底方块、Natural High 红底、Hon Naka 64×64 青底)——底色是设计的一部分:接近方形的原字节返回,长条按边缘主色补方(`pad_to_square`)。不刷白。+ 两条路的产物都再过一遍 `refit_plate`,因为方图**摆得不对**和**不是方图**是两件事:小圆片铺满的是+ 整张画布不是内容,源站 favicon 常自带大留白(Flower 的金环占宽 0.24、いんすた 0.30、Planet_Plus 0.31、+ まんまんランド 0.55、EST 0.56),铺进 32 px 圆片就小得认不出;反过来顶到边的实心方标四角落在圆外,+ MARRION 的金框和 Tushy 的「T」直接看不见。内容占宽低于 `PLATE_MIN_SPAN`(0.6)裁到内容框、四周留+ 12%;内容落在内切圆之外的比例超过 `PLATE_CIRCLE_LOSS`(0.025)把画布补到内容的外接圆。像素一律+ 不缩放,所以裁出来的更小但更清晰、补出来的更大而清晰度不变。断点都是实测的:占宽下一档 FC2-PPV+ 0.62 起看着正常,圆外损失落在 T-POWERS 0.019 与 TEPPAN 0.034 之间,圆形图标(Wanz Factory 0.008)+ 不受影响。内容框按行列统计,只有零星几个像素的行列不算内容——有损压缩在纯色区留下的淡斑点会把+ 逐像素外接框撑满整张画布(EST 的字样只占纵向 249 行,斑点却让框横跨 685 行)。写入侧只有两条路径,规则同一条:`harvest_studio_icons.py` 的 `install()` 落盘前烤,`normalize_studio_logos.py` 对历史文件回溯(目录下所有 `*.img`,含 `.icon.img`/`.logo.img`)。两者都幂等——烤出来的产物再跑一次不再有动作。女优头像等照片不走这条路径,不加白边。@@ -532,16 +541,26 @@ Windows 空数据预览的项目 CA HTTPS、合成 Cookie 保存/撤销、DMM走 `peach.images.bake_square_vector`:同样的 76% 边距,但方底由外层 SVG 给,原文档整个塞进嵌套 `<svg>`,一个节点都不改写——栅格化会把「放多大都清晰」这个唯一优势丢掉。内容框直接取`viewBox`:4 张渲染后实测,决定方框边长的长边都是 tight 的(横向占满 0.97~1.00),- 纵向留白只影响居中。**底色不写死白**:栅格化一张 256 px 探针数内容像素,在白底上还看得见的- 比例低于 `PLATE_VISIBLE_RATIO`(0.7)就配深底 `#111111`。DarkRoomVR 的「DARK ROOM」和- TeamSkeetXReislin 的「TEAM」都是白字,白底可见率实测 0.20 与 0.52,配白底等于把半个标识抹掉;- TeenFidelity 0.82、VirtualTaboo 1.00 仍走白底。位图那条路目前仍一律白底——已装的 26 张- 实测没有一张被白底吞掉,不为一个没出现的情况改动既有产物。- 外层根元素上留 `data-peach-plate="1"`,重跑据此跳过——矢量没有像素可读,不靠这个标记就会越套越多。- `viewBox`、`width`/`height` 都没有的空壳量不出比例,仍记 `vector` 原样留着。- 位图那批已经回溯完(26 个 `mark` 烤白底、5 个长条补方,边车在 `*.img.normalization.json`);- 2026-09-07 的 dry-run 只剩 4 个 `would-plate`,都是上面那 4 张矢量。回溯真实目录需另行授权。- 页面三处取图位(品牌小圆片 `.brandpill .mk`、身份格 `.idface`、厂牌页 160 px 大位 `.entityportrait`)+ 纵向留白只影响居中。矢量没有像素可读,外层根元素上留 `data-peach-plate="1"` 让重跑据此跳过,+ 不靠这个标记就会越套越多。`viewBox`、`width`/`height` 都没有的空壳量不出比例,仍记 `vector`+ 原样留着。+- **底色按内容明暗判,位图和矢量同一条规则**(`images._plate_color`;矢量先栅格化一张 256 px 探针数+ 像素,产物仍是矢量)。只有笔画直接挨着底色的稀疏标识会被底色吞掉:内容框里的不透明覆盖低于+ `PLATE_SOLID_COVER`(0.9)才判底色,白底上还看得见的比例低于 `PLATE_VISIBLE_RATIO`(0.7)就配深底+ `#111111`。DarkRoomVR 的「DARK ROOM」、TeamSkeetXReislin 的「TEAM」、HEYZO 的「HEY」都是白笔画,+ 白底可见率实测 0.20、0.52、0.44,配白底等于把半个标识抹掉。自带整块底的另说:Fitch 的白卡片覆盖+ 0.98、Hunter 的迷彩方块 1.00,它们的边界是自己画的,外面那圈只是画框,配深底反而让那块底浮在黑里。+- **归一从原图开始。** 装上去的文件如果记着备份原图、备份又还在本机,`normalize_studio_logos.py` 拿+ 备份当输入:烤底毁掉的透明通道和配错的底色在产物上判不回来,从原图重来才能让算法的改进落到已经+ 装好的文件上(HEYZO 就是这么修回来的)。边车继续指向原图,别把指针改指到这一轮备份的归一产物。+ 边车的 `action` 是认来路的稳定标识不是描述:`bake-white-plate`、`pad-to-square`、`refit-plate`、+ `plate-vector`。`harvest_studio_icons.padded_studios` 按 `pad-to-square` 认「这一张的源图是条状字标」,+ 把重新摆位记成补方等于污染那份名单,所以三条位图路径分开记。+ 已装的位图里 26 个 `mark` 烤过底、5 个长条补过方(边车在 `*.img.normalization.json`);2026-09-08 的+ dry-run 报 52 个待改:46 个重新摆位、4 个矢量包方底、HEYZO 改配深底、pikpak 重补方。+ 回溯真实目录需另行授权。+- **页面三处取图位统一铺满,不各自补救。**+ 三处(品牌小圆片 `.brandpill .mk`、身份格 `.idface`、厂牌页 160 px 大位 `.entityportrait`)的 `img` 统一 `object-fit: cover` 铺满方框,不加 inset、不加 padding、不改 contain:文件已经带够边距,页面再补一层就在图自带的底之外多围出一圈框,而三处各自补救的结果必然互相不一致。占位底色(`#CFCFCF`、`#fff`、`--overlay-5`)与首字母回落只在取不到图时露出来。diff --git a/scripts/harvest_studio_icons.py b/scripts/harvest_studio_icons.pyindex befbd00fa..83a101232 100644--- a/scripts/harvest_studio_icons.py+++ b/scripts/harvest_studio_icons.py@@ -856,8 +856,8 @@ def icon_from_logo(safe: str, target: dict[str, str], logo: dict[str, object],url=str(logo["url"]), link_kind="logo-source",evidence="指定的 logo 来源烤不成方图")# 判「补没补白」看源图自己的长宽,不看内容比:`images.MAX_ASPECT` 正是 `bake_square`- # 「够方就原样返回」的那条线,所以 `ok` 恰好等于这一张一个像素都没动过。名录里的- # jpg 是整幅不透明的,内容比对它一律回 0,拿那个数分不出方图和长条。+ # 把长条补成方图的那条线。方图也可能被重新摆位,但那不是补白。名录里的 jpg 是整幅+ # 不透明的,内容比对它一律回 0,拿那个数分不出方图和长条。width, height = (int(value) for value in str(logo["mark_size"]).split("x"))wide = max(width, height) / min(width, height) > images.MAX_ASPECTaspect = link_marks.content_aspect(image)diff --git a/scripts/normalize_studio_logos.py b/scripts/normalize_studio_logos.pyindex 9866217a5..6c23c834b 100644--- a/scripts/normalize_studio_logos.py+++ b/scripts/normalize_studio_logos.py@@ -1,10 +1,13 @@"""把已安装的厂牌 Logo 归一成不透明方图。页面三处取图位都用 `object-fit: cover` 铺满方框,所以文件本身必须是不透明方图:-带透明像素的独立图标烤上白底,不透明的长条按边缘主色补方,已经是不透明方图的-跳过。目录下所有 `*.img` 都在范围内,`<safe>.icon.img` 与 `<safe>.logo.img` 一样算。-矢量标识(`image/svg+xml`)走同样的边距,方底由外层 SVG 包出来,不栅格化,底色按-内容明暗判;连内容框都没声明、比例无从算起的原样留着并在复核件上记 `vector`。+带透明像素的独立图标烤上底色,不透明的长条按边缘主色补方,方图里内容太小或者+会被圆片切掉的重新摆一遍。目录下所有 `*.img` 都在范围内,`<safe>.icon.img` 与+`<safe>.logo.img` 一样算。矢量标识(`image/svg+xml`)走同样的边距,方底由外层 SVG+包出来,不栅格化;连内容框都没声明、比例无从算起的原样留着并记 `vector`。++归一从原图开始:装上去的文件如果记着备份原图,就拿备份当输入,因为烤底会毁掉+透明通道,在产物上再叠一层永远追不回原图能给的结果。默认只报告;显式 ``--apply`` 时必须提供独立备份目录,原图和边车会先备份,再原子替换。@@ -28,8 +31,8 @@ if str(SRC_DIR) not in sys.path:from peach.config import GENERATED_DIRfrom peach.scripting import BACKUP_REQUIRED-from peach.images import (MARK, bake_square, bake_square_vector, classify_plate,- measure_image_size, vector_image_size)+from peach.images import (MARK, MAX_ASPECT, bake_square, bake_square_vector,+ classify_plate, measure_image_size, vector_image_size)from peach.review_csv import write_rows@@ -38,16 +41,19 @@ FIELDS = ("after_sha256", "backup",)-# 边车里记的动作名。`harvest_studio_icons.padded_studios` 按 PAD_ACTION 认「这一张-# 的源图是条状字标」,改名等于把那份名单清空。+# 边车里记的动作名,是认已装文件来路的稳定标识,不是描述。`harvest_studio_icons+# .padded_studios` 按 PAD_ACTION 认「这一张的源图是条状字标」,改名等于把那份名单+# 清空;BAKE_ACTION 同理带着 white 字样,实际底色按内容明暗判,见 `images._plate_color`。BAKE_ACTION = "bake-white-plate"PAD_ACTION = "pad-to-square"-# 矢量标识包白底方框,是 SVG 进 SVG 出,和位图的两个动作分开记。+# 已经是方图、只是重新摆了位置的:内容太小裁掉留白,或者补大到内容的外接圆。+REFIT_ACTION = "refit-plate"+# 矢量标识包方底,是 SVG 进 SVG 出,和位图的三个动作分开记。PLATE_ACTION = "plate-vector"# 量不出内容框的矢量标识:没动,在复核件上单列。VECTOR = "vector"CHANGED_ACTIONS = frozenset({"would-bake", "baked", "would-pad", "padded",- "would-plate", "plated"})+ "would-refit", "refitted", "would-plate", "plated"})def _digest(payload: bytes) -> str:@@ -76,24 +82,49 @@ def _backup_family(source: Path, backup_dir: Path) -> None:shutil.copy2(candidate, backup_dir / candidate.name)+def _origin(path: Path, installed: bytes) -> tuple[bytes, str]:+ """归一的输入和它的备份路径。++ 边车记着备份原图、备份又还在本机时,输入取备份:烤底毁掉的透明通道和配错的+ 底色在产物上判不回来,从原图重来才能让算法的改进落到已经装好的文件上。备份+ 不在本机就只能拿现装的文件当输入,并在这一轮重新建立备份。+ """+ sidecar = Path(f"{path}.normalization.json")+ if not sidecar.is_file():+ return installed, ""+ try:+ recorded = json.loads(sidecar.read_text(encoding="utf-8"))+ except (OSError, ValueError):+ return installed, ""+ backup = Path(str(recorded.get("backup") or ""))+ if not backup.is_file():+ return installed, ""+ return backup.read_bytes(), str(backup)++def _install(path: Path, payload: bytes, normalized: bytes, *, kind: str,sidecar_action: str, width: float, height: float, content_type: bytes,- backup_dir: Path) -> str:- """备份原图,原子替换,留下复核用的边车;返回备份路径。"""+ backup_dir: Path, origin: str = "") -> str:+ """备份现装的一家子,原子替换,留下复核用的边车;返回原图备份路径。++ `origin` 非空表示输入本来就是上一轮留下的备份原图,边车继续指向它,别让指针+ 改指到这一轮备份的归一产物上。+ """_backup_family(path, backup_dir)_atomic_bytes(path, normalized)_atomic_bytes(Path(f"{path}.ct"), content_type)+ recorded_backup = origin or str(backup_dir / path.name)evidence = {"action": sidecar_action,"normalized_at": datetime.now(timezone.utc).isoformat(),"kind": kind,"original_width": width, "original_height": height,"original_sha256": _digest(payload), "normalized_sha256": _digest(normalized),- "backup": str(backup_dir / path.name),+ "backup": recorded_backup,}_atomic_bytes(Path(f"{path}.normalization.json"),json.dumps(evidence, ensure_ascii=False, indent=2).encode("utf-8"))- return str(backup_dir / path.name)+ return recorded_backupdef normalize(root: Path, *, apply: bool = False,@@ -107,21 +138,22 @@ def normalize(root: Path, *, apply: bool = False,raise ValueError("备份目录必须在 Logo 目录之外")rows: list[dict[str, object]] = []for path in sorted(root.glob("*.img")):- payload = path.read_bytes()+ installed = path.read_bytes()+ payload, origin = _origin(path, installed)size = measure_image_size(payload)kind = classify_plate(payload)if _is_vector(path, payload):- # 矢量不栅格化:白底和边距由外层 SVG 包出来,原文档一个节点都不动。+ # 矢量不栅格化:方底和边距由外层 SVG 包出来,原文档一个节点都不动。# 包不出来的(不是 SVG、或者连内容框都没声明)原样留着并单列,不冒充已归一。plated = bake_square_vector(payload)box = vector_image_size(payload)if plated is None or box is None:rows.append({"file": path.name, "width": "", "height": "", "aspect": "","kind": VECTOR, "action": "vector",- "before_sha256": _digest(payload),+ "before_sha256": _digest(installed),"after_sha256": "", "backup": ""})continue- if plated == payload:+ if plated == installed:# 已经包过方底,一个字节都不用动。continuebox_width, box_height = box@@ -132,17 +164,17 @@ def normalize(root: Path, *, apply: bool = False,backup = _install(path, payload, plated, kind=VECTOR,sidecar_action=PLATE_ACTION, width=box_width,height=box_height, content_type=b"image/svg+xml",- backup_dir=backup_dir)+ backup_dir=backup_dir, origin=origin)action = "plated"rows.append({"file": path.name, "width": box_width, "height": box_height,"aspect": round(max(box) / min(box), 3), "kind": VECTOR,- "action": action, "before_sha256": _digest(payload),+ "action": action, "before_sha256": _digest(installed),"after_sha256": _digest(plated), "backup": backup})continueif not size or kind is None:rows.append({"file": path.name, "width": "", "height": "", "aspect": "","kind": kind or "", "action": "invalid",- "before_sha256": _digest(payload),+ "before_sha256": _digest(installed),"after_sha256": "", "backup": ""})continuewidth, height = size@@ -151,26 +183,32 @@ def normalize(root: Path, *, apply: bool = False,if baked is None:rows.append({"file": path.name, "width": width, "height": height,"aspect": round(aspect, 3), "kind": kind, "action": "invalid",- "before_sha256": _digest(payload), "after_sha256": "",+ "before_sha256": _digest(installed), "after_sha256": "","backup": ""})continue- if baked == payload:- # 已经是不透明方图,一个字节都不用动。+ if baked == installed:+ # 已经摆好的不透明方图,一个字节都不用动。continue- planned, done, sidecar_action = (- ("would-bake", "baked", BAKE_ACTION) if kind == MARK- else ("would-pad", "padded", PAD_ACTION))+ # 动作按原图走的那条分支记,不按结果长相认:`harvest_studio_icons.padded_studios`+ # 靠 PAD_ACTION 认「这一张的源图是条状字标」,把重新摆位记成补方等于污染那份名单。+ if kind == MARK:+ planned, done, sidecar_action = "would-bake", "baked", BAKE_ACTION+ elif aspect > MAX_ASPECT:+ planned, done, sidecar_action = "would-pad", "padded", PAD_ACTION+ else:+ planned, done, sidecar_action = "would-refit", "refitted", REFIT_ACTIONaction = plannedbackup = ""if apply:assert backup_dir is not Nonebackup = _install(path, payload, baked, kind=kind,sidecar_action=sidecar_action, width=width, height=height,- content_type=b"image/png", backup_dir=backup_dir)+ content_type=b"image/png", backup_dir=backup_dir,+ origin=origin)action = donerows.append({"file": path.name, "width": width, "height": height,"aspect": round(aspect, 3), "kind": kind, "action": action,- "before_sha256": _digest(payload), "after_sha256": _digest(baked),+ "before_sha256": _digest(installed), "after_sha256": _digest(baked),"backup": backup})return rowsdiff --git a/src/peach/images.py b/src/peach/images.pyindex 0e44da9f1..5ccbc6c9c 100644--- a/src/peach/images.py+++ b/src/peach/images.py@@ -6,9 +6,10 @@厂牌标识另有一层:页面三处取图位(品牌小圆片、身份格、厂牌页大位)都用`object-fit: cover` 铺满方框,所以文件本身必须是不透明方图。`bake_square` 是-位图这条规则的唯一入口,`classify_plate` 给出它据以分流的判定。矢量标识走-`bake_square_vector`:同样的边距,但方底用外层 SVG 包出来,不栅格化;底色按内容-明暗判,白字标配深底。+位图这条规则的唯一入口,`classify_plate` 给出它据以分流的判定,`refit_plate` 再把+方图摆到圆形图位里看得全的位置。矢量标识走 `bake_square_vector`:同样的边距,但+方底用外层 SVG 包出来,不栅格化。底色两条路同一条规则(`_plate_color`),按内容+明暗判,白笔画配深底。女优头像等照片不走这条路径,只走 `classify` 与 `pad_to_square`。"""from __future__ import annotations@@ -17,8 +18,9 @@ import ioimport reimport xml.etree.ElementTree as ElementTreefrom collections import Counter+from math import ceil, hypot-from PIL import Image, ImageChops+from PIL import Image, ImageChops, ImageDraw# 长边/短边在这个值以内视为「已经够方」,直接用原图。MAX_ASPECT = 1.35@@ -43,10 +45,30 @@ PLATE_DARK_BACKGROUND = (17, 17, 17, 255)# DarkRoomVR 0.20、TeamSkeetXReislin 0.52 会被白底吞掉,TeenFidelity 0.82、# VirtualTaboo 1.00 不受影响,阈值落在中间两侧都有余量。PLATE_VISIBLE_RATIO = 0.7+# 内容框里的不透明覆盖到这个比例就算自带整块底,底色只当画框,一律白。真实标识+# 实测:稀疏笔画的 HEYZO 0.52、TeamSkeetXReislin 0.56 要判底色,自带底的 Fitch+# 0.98、Hunter 1.00 不必判,阈值落在中间。+PLATE_SOLID_COVER = 0.9# 判底色用的探针尺寸。只用来数像素,产物仍是原矢量。PLATE_PROBE_SIZE = 256# 亮度离白多远才算「在白底上看得见」。PLATE_INK_CONTRAST = 40+# 离底色多远才算内容。方图的底色是设计的一部分,压不到这个差的算同一块底。+PLATE_GROUND_TOLERANCE = 24+# 内容外接框长边占方图边长低于这个数,就裁掉多余留白。真实目录实测:+# Flower 0.24、いんすた 0.30、Planet_Plus 0.31、まんまんランド 0.55、EST 0.56 都是+# 源站 favicon 自带的大留白,铺进 32 px 圆片后内容小得认不出;下一档 FC2-PPV 0.62+# 起看着正常,阈值落在这个断点上。+PLATE_MIN_SPAN = 0.6+# 内容落在内切圆之外的比例超过这个数,就把方图补大到内容的外接圆。小圆片+# (`.brandpill .mk`)是圆的,方图四角在圆外,那部分内容直接看不见。实测断点:+# T-POWERS 0.019 与 TEPPAN 0.034 之间;圆形图标(Wanz Factory 0.008)不受影响。+PLATE_CIRCLE_LOSS = 0.025+# 一行(或一列)里的内容像素不多于内容总量这个比例就算杂点。有损压缩会在纯色区+# 留下极淡的斑点,逐像素的外接框被它们撑满整张画布:EST 的字样只占纵向 249 行,+# 杂点却让框横跨 685 行。下限挡住内容本来就很少的小图。+PLATE_NOISE_RATIO = 0.0005+PLATE_NOISE_FLOOR = 3SVG_NS = "http://www.w3.org/2000/svg"XLINK_NS = "http://www.w3.org/1999/xlink"@@ -112,9 +134,10 @@ def classify_plate(payload: bytes) -> str | None:def bake_square(payload: bytes) -> bytes | None:"""把厂牌标识烤成不透明方图,返回 PNG 字节;解析失败返回 None。- 独立图标裁掉透明边后居中放到白色方底上,内容占边长- `PLATE_CONTENT_RATIO`。整块底图接近方形就原样返回原字节,长条按边缘主色- 补方。原始像素一律不缩放,方图边长由内容尺寸推出来。+ 独立图标裁掉透明边后居中放到方底上,内容占边长 `PLATE_CONTENT_RATIO`,底色+ 按内容明暗判。整块底图接近方形就沿用它自己的底,长条按边缘主色补方。两条路+ 最后都过一遍 `refit_plate`:内容在画布里的占比也是取图位看得见的东西,+ 只看长宽比会让 0.24 和 0.95 一起原样通过。原始像素一律不缩放。"""image = _open_rgba(payload)if image is None:@@ -124,18 +147,132 @@ def bake_square(payload: bytes) -> bytes | None:return Noneif not _has_transparency(image):if max(width, height) / min(width, height) <= MAX_ASPECT:- return payload- return pad_to_square(payload)+ squared = payload+ else:+ squared = pad_to_square(payload)+ if squared is None:+ return None+ return refit_plate(squared) or squaredbox = image.getchannel("A").getbbox()if box is None:return Nonecontent = image.crop(box)side = max(max(content.size), round(max(content.size) / PLATE_CONTENT_RATIO))- canvas = Image.new("RGBA", (side, side), PLATE_BACKGROUND)+ canvas = Image.new("RGBA", (side, side), _plate_color(image))canvas.paste(content, ((side - content.width) // 2, (side - content.height) // 2),content)buffer = io.BytesIO()canvas.convert("RGB").save(buffer, "PNG")+ baked = buffer.getvalue()+ return refit_plate(baked) or baked+++def _ink_mask(image: Image.Image, ground: tuple[int, int, int, int]) -> Image.Image:+ """离底色够远的那些像素。返回只有 0 / 255 的单通道图。"""+ plate = Image.new("RGB", image.size, ground[:3])+ return ImageChops.difference(image.convert("RGB"), plate).convert("L").point(+ lambda value: 255 if value > PLATE_GROUND_TOLERANCE else 0)+++def _ink_extent(mask: Image.Image, floor: int) -> tuple[int, int] | None:+ """内容像素多于 `floor` 的那些行的首末位置,末位是开区间。"""+ width = mask.width+ data = mask.tobytes()+ rows = [index for index in range(mask.height)+ if data[index * width:(index + 1) * width].count(255) > floor]+ if not rows:+ return None+ return rows[0], rows[-1] + 1+++def _content_box(mask: Image.Image) -> tuple[int, int, int, int] | None:+ """内容外接框,只有零星几个像素的行列不算内容。"""+ total = mask.histogram()[255]+ if not total:+ return None+ floor = max(PLATE_NOISE_FLOOR, round(total * PLATE_NOISE_RATIO))+ rows = _ink_extent(mask, floor)+ columns = _ink_extent(mask.transpose(Image.Transpose.TRANSPOSE), floor)+ if rows is None or columns is None:+ return None+ return columns[0], rows[0], columns[1], rows[1]+++def _content_radius(mask: Image.Image, box: tuple[int, int, int, int]) -> float:+ """内容相对自己外接框中心的最大距离,也就是它的外接圆半径。++ 只看每一行最左、最右那两个内容像素:同一行里离中心最远的必然是这两个之一,+ 所以逐行取一次 `getbbox()` 就够,不必遍历上百万像素。+ """+ center_x = (box[0] + box[2] - 1) / 2+ center_y = (box[1] + box[3] - 1) / 2+ width = mask.width+ radius = 0.0+ for y in range(box[1], box[3]):+ row = mask.crop((0, y, width, y + 1)).getbbox()+ if row is None:+ continue+ for x in (row[0], row[2] - 1):+ radius = max(radius, hypot(x - center_x, y - center_y))+ return radius+++def refit_plate(payload: bytes) -> bytes | None:+ """把不透明方图重新摆一遍:内容既不小到发空,也不大到被圆片切掉。++ 两件事都是取图位真的看得见的:小圆片(`.brandpill .mk`)是 32 px 圆、`cover`+ 铺满,所以铺满的是整张画布,不是内容——源站 favicon 常自带大留白(Flower 的+ 金环只占 0.24),铺进去就小得认不出;反过来顶到边的实心方标(MARRION 0.95)+ 四角落在圆外,金框和字样直接看不见。++ 动手只有两种:内容太小就裁掉多余留白,会被圆切就把画布补到内容的外接圆。+ 像素一律不缩放,所以裁出来的图更小但更清晰,补出来的图更大而清晰度不变。+ 两者都不适用时返回原字节;`None` 只表示解析不了。+ """+ image = _open_rgba(payload)+ if image is None:+ return None+ width, height = image.size+ if not width or not height:+ return payload+ if max(width, height) / min(width, height) > MAX_ASPECT:+ # 横幅字标本来就不是方的,摆进圆片这件事由 `pad_to_square` 负责。+ return payload+ if _has_transparency(image):+ # 带透明的还没配底,`_background_color` 会给回透明,补出来的边会变成黑块。+ # 这一步只收 `bake_square` 已经配好底的产物和目录里那些不透明方图。+ return payload+ ground = _background_color(image)+ box = _content_box(_ink_mask(image, ground))+ if box is None:+ # 整张一个色(占位底板那类),没有内容框可言。+ return payload+ # 框外的杂点不参与后面的圆外损失和外接圆,否则一个斑点就能把画布撑到两倍。+ mask = Image.new("L", image.size, 0)+ mask.paste(_ink_mask(image.crop(box), ground), box[:2])+ span = max(box[2] - box[0], box[3] - box[1])+ # 圆片是 `cover`:长边被切掉,露出来的是居中那个短边见方的区域的内切圆。+ short = min(width, height)+ left = (width - short) // 2+ top = (height - short) // 2+ circle = Image.new("L", image.size, 0)+ ImageDraw.Draw(circle).ellipse(+ (left, top, left + short - 1, top + short - 1), fill=255)+ total = mask.histogram()[255]+ inside = ImageChops.multiply(mask, circle).histogram()[255]+ lost = 1 - inside / total if total else 0.0+ side = 0+ if span / short < PLATE_MIN_SPAN:+ side = round(span / PLATE_CONTENT_RATIO)+ if lost > PLATE_CIRCLE_LOSS:+ side = max(side, ceil(_content_radius(mask, box) * 2))+ if side <= 0 or (side == width and side == height):+ return payload+ content = image.crop(box)+ canvas = Image.new("RGBA", (side, side), ground)+ canvas.paste(content, ((side - content.width) // 2, (side - content.height) // 2))+ buffer = io.BytesIO()+ canvas.convert("RGB").save(buffer, "PNG")return buffer.getvalue()@@ -144,25 +281,23 @@ def _svg_number(value: float) -> str:return f"{value:.10g}"-def _vector_plate_color(payload: bytes) -> tuple[int, int, int, int]:- """这张矢量标识该配白底还是深底。+def _plate_color(image: Image.Image) -> tuple[int, int, int, int]:+ """这张标识该配白底还是深底。- 栅格化只用来数像素,产物仍是矢量:把它渲染一遍,看内容里有多少在白底上还- 看得见。DarkRoomVR 的「DARK ROOM」和 TeamSkeetXReislin 的「TEAM」都是白字,- 配白底等于把半个标识抹掉——实测白底可见率 0.20 与 0.52,深底才是它们的本相。- 渲染不出来(`resvg_py` 缺席或图有问题)按白底走,和位图的 `MARK` 一致。+ 只有笔画直接挨着底色的稀疏标识才会被底色吞掉:HEYZO 的「HEY」、DarkRoomVR 的+ 「DARK ROOM」都是白笔画摆在透明底上,白底可见率 0.44 与 0.20,配白底等于把那+ 部分抹掉,深底才是它们的本相。自带整块底的(Fitch 的白卡片、Hunter 的迷彩方块,+ 内容框里的不透明覆盖 0.98 与 1.00)另说:它们的边界是自己画的,外面那圈底色+ 只是画框,配深底反而让那块卡片浮在黑里。透明像素不算内容。"""- from .link_marks import rasterize_svg-- rendered = rasterize_svg(payload, PLATE_PROBE_SIZE)- image = _open_rgba(rendered) if rendered else None- if image is None:- return PLATE_BACKGROUNDink = image.getchannel("A").point(lambda value: 255 if value >= 128 else 0)lit = image.convert("L").point(lambda value: 255 if value < 255 - PLATE_INK_CONTRAST else 0)+ box = ink.getbbox()total = ink.histogram()[255]- if not total:+ if not total or box is None:+ return PLATE_BACKGROUND+ if total / ((box[2] - box[0]) * (box[3] - box[1])) >= PLATE_SOLID_COVER:return PLATE_BACKGROUNDvisible = ImageChops.multiply(ink, lit).histogram()[255]if visible / total >= PLATE_VISIBLE_RATIO:@@ -170,6 +305,18 @@ def _vector_plate_color(payload: bytes) -> tuple[int, int, int, int]:return PLATE_DARK_BACKGROUND+def _vector_plate_color(payload: bytes) -> tuple[int, int, int, int]:+ """矢量标识的底色。栅格化只用来数像素,产物仍是矢量。++ 渲染不出来(`resvg_py` 缺席或图有问题)按白底走,和判不出内容时一致。+ """+ from .link_marks import rasterize_svg++ rendered = rasterize_svg(payload, PLATE_PROBE_SIZE)+ image = _open_rgba(rendered) if rendered else None+ return PLATE_BACKGROUND if image is None else _plate_color(image)++def _svg_length(value: str | None) -> float | None:matched = _SVG_LENGTH.match((value or "").strip())if matched is None:diff --git a/tests/test_logo_provider.py b/tests/test_logo_provider.pyindex 62db3c740..5066b2c96 100644--- a/tests/test_logo_provider.py+++ b/tests/test_logo_provider.py@@ -8,6 +8,7 @@ from pathlib import Pathfrom PIL import Image, ImageDraw+from peach.images import bake_squarefrom peach.logo_provider import LogoCandidateCache, inspect_logo@@ -132,7 +133,10 @@ class StudioLogoScriptTests(unittest.TestCase):self.assertEqual(health["errors"], "0")def test_same_installed_content_is_mechanical_unchanged(self):- (self.installed / "Studio_A.img").write_bytes(pattern_png(size=(400, 400)))+ # 装着的那张也过 `bake_square`:目录里的文件都是这么来的,拿没归一的原图+ # 当在位图,比的就不是「同一张图换了尺寸」而是归一本身带来的差别。+ (self.installed / "Studio_A.img").write_bytes(+ bake_square(pattern_png(size=(400, 400))))refreshed = pattern_png(size=(200, 200))self.assertEqual(self.module.main(self.args(), transport=FakeTransport([refreshed])), 0)row = self.rows()[0]diff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex a713014b5..984ec2ed0 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -923,6 +923,104 @@ class OperationalScriptTests(unittest.TestCase):self.assertIsNone(classify_plate(b"not an image"))self.assertIsNone(bake_square(b"not an image"))+ def test_the_plate_colour_follows_the_marks_own_brightness(self):+ """浅色笔画配深底,自带整块底的一律白底。++ 笔画直接挨着底色的标识才会被底色吞掉:白笔画配白底等于把它抹掉。自带整+ 块底的标识边界是自己画的,外面那圈只是画框,配深底反而让那块底浮在黑里。+ """+ import io++ from PIL import Image++ from peach.images import bake_square++ def png(image):+ buffer = io.BytesIO()+ image.save(buffer, "PNG")+ return buffer.getvalue()++ strokes = Image.new("RGBA", (200, 60), (0, 0, 0, 0))+ for x in list(range(20, 80)) + list(range(120, 180)):+ for y in range(10, 50):+ strokes.putpixel((x, y), (255, 255, 255, 255))+ with Image.open(io.BytesIO(bake_square(png(strokes)))) as plate:+ self.assertEqual(plate.convert("RGB").getpixel((2, 2)), (17, 17, 17),+ "白笔画配深底才看得见")++ card = Image.new("RGBA", (200, 60), (0, 0, 0, 0))+ for x in range(20, 180):+ for y in range(10, 50):+ card.putpixel((x, y), (255, 255, 255, 255))+ for x in range(60, 140):+ for y in range(24, 36):+ card.putpixel((x, y), (196, 20, 24, 255))+ with Image.open(io.BytesIO(bake_square(png(card)))) as plate:+ self.assertEqual(plate.convert("RGB").getpixel((2, 2)), (255, 255, 255),+ "自带整块白底的标识,外面那圈跟着它一起白")++ def test_a_square_plate_is_refit_so_the_round_slot_shows_the_whole_mark(self):+ """不透明方图重新摆位:内容太小裁掉留白,会被圆片切掉就补到外接圆。++ 小圆片(`.brandpill .mk`)是 32 px 圆、`cover` 铺满,铺满的是整张画布不是+ 内容。源站 favicon 常自带大留白,铺进去内容小得认不出;顶到边的实心方标+ 四角落在圆外,那部分直接看不见。像素一律不缩放。+ """+ import io+ from math import ceil, hypot++ from PIL import Image, ImageDraw++ from peach.images import PLATE_CONTENT_RATIO, refit_plate++ def png(image):+ buffer = io.BytesIO()+ image.save(buffer, "PNG")+ return buffer.getvalue()++ def side(payload):+ with Image.open(io.BytesIO(payload)) as opened:+ self.assertEqual(opened.size[0], opened.size[1])+ return opened.size[0]++ roomy = Image.new("RGB", (200, 200), (255, 255, 255))+ ImageDraw.Draw(roomy).rectangle((80, 80, 119, 119), fill=(196, 20, 24))+ cropped = refit_plate(png(roomy))+ self.assertEqual(side(cropped), round(40 / PLATE_CONTENT_RATIO),+ "裁到内容框,四周各留约 12%")+ with Image.open(io.BytesIO(cropped)) as plate:+ self.assertEqual(plate.getpixel((plate.width // 2, plate.height // 2)),+ (196, 20, 24), "像素不缩放,只是换了画布")+ self.assertEqual(refit_plate(cropped), cropped, "摆好的不再动")++ speckled = roomy.copy()+ for spot in ((3, 3), (196, 4), (5, 195), (194, 197)):+ speckled.putpixel(spot, (250, 250, 250))+ self.assertEqual(side(refit_plate(png(speckled))), side(cropped),+ "有损压缩留下的零星斑点不算内容,撑不开内容框")++ packed = Image.new("RGB", (200, 200), (255, 255, 255))+ ImageDraw.Draw(packed).rectangle((10, 10, 189, 189), fill=(196, 20, 24))+ padded = refit_plate(png(packed))+ self.assertEqual(side(padded), ceil(hypot(179, 179)),+ "补到内容的外接圆,直径就是内容框的对角线,四角不再被圆片切掉")+ with Image.open(io.BytesIO(padded)) as plate:+ self.assertEqual(plate.getpixel((2, 2)), (255, 255, 255),+ "补出来的边取原图底色")++ circular = Image.new("RGB", (200, 200), (255, 255, 255))+ ImageDraw.Draw(circular).ellipse((0, 0, 199, 199), fill=(196, 20, 24))+ payload = png(circular)+ self.assertEqual(refit_plate(payload), payload, "本来就是圆的图标一个字节不动")++ strip = png(Image.new("RGB", (400, 100), (196, 20, 24)))+ self.assertEqual(refit_plate(strip), strip, "条状字标的摆位归 pad_to_square 管")++ transparent = png(Image.new("RGBA", (200, 200), (0, 0, 0, 0)))+ self.assertEqual(refit_plate(transparent), transparent,+ "还没配底的图没有底色可取,补出来的边会变成黑块")+ self.assertIsNone(refit_plate(b"not an image"))+def test_a_vector_mark_gets_the_same_plate_without_rasterising(self):"""矢量标识:白底和边距一样烤进文件,但是包一层外层 SVG,原文档不动。@@ -964,14 +1062,20 @@ class OperationalScriptTests(unittest.TestCase):# 白字标配白底等于把标识抹掉:DarkRoomVR 的「DARK ROOM」和# TeamSkeetXReislin 的「TEAM」都是白的,白底可见率 0.20 与 0.52。- pale = bake_square_vector(svg('<rect x="10" y="10" width="187" height="50" '- 'fill="#ffffff"/>'))+ def strokes(color):+ return svg(f'<rect x="10" y="10" width="60" height="50" fill="{color}"/>'+ f'<rect x="137" y="10" width="60" height="50" fill="{color}"/>')++ pale = bake_square_vector(strokes("#ffffff"))self.assertEqual(ElementTree.fromstring(pale)[0].get("fill"), "#111111","浅色内容改配深底")self.assertEqual(- ElementTree.fromstring(bake_square_vector(svg(- '<rect x="10" y="10" width="187" height="50" fill="#101820"/>')))[0]+ ElementTree.fromstring(bake_square_vector(strokes("#101820")))[0].get("fill"), "#ffffff", "深色内容仍是白底,和位图的 mark 一条规则")+ self.assertEqual(+ ElementTree.fromstring(bake_square_vector(svg(+ '<rect x="10" y="10" width="187" height="50" fill="#ffffff"/>')))[0]+ .get("fill"), "#ffffff", "自带整块底的标识不判底色,外面那圈跟着它一起白")# 空壳没有 viewBox 也没有 width/height:比例无从算起,方框边长也就无从定。self.assertIsNone(vector_image_size(b'<svg xmlns="http://www.w3.org/2000/svg"/>'))self.assertIsNone(bake_square_vector(b'<svg xmlns="http://www.w3.org/2000/svg"/>'))@@ -1016,6 +1120,10 @@ class OperationalScriptTests(unittest.TestCase):for x in range(20, 180):for y in range(10, 50):mark.putpixel((x, y), (0, 174, 239, 255))+ roomy = Image.new("RGB", (200, 200), (255, 255, 255))+ for x in range(80, 120):+ for y in range(80, 120):+ roomy.putpixel((x, y), (196, 20, 24))with tempfile.TemporaryDirectory() as tmp:root = Path(tmp).resolve() / "logos"@@ -1024,6 +1132,7 @@ class OperationalScriptTests(unittest.TestCase):originals = {"wide.img": png(Image.new("RGB", (400, 100), (196, 20, 24))),"flat.icon.img": png(Image.new("RGB", (256, 256), (12, 12, 12))),+ "spot.icon.img": png(roomy),"sign.logo.img": png(mark),"vector.img": b'<svg xmlns="http://www.w3.org/2000/svg"/>',"sign.icon.img": ('<svg xmlns="http://www.w3.org/2000/svg" '@@ -1042,6 +1151,9 @@ class OperationalScriptTests(unittest.TestCase):self.assertEqual(dry["wide.img"]["kind"], "tile")self.assertEqual(dry["sign.logo.img"]["action"], "would-bake")self.assertEqual(dry["sign.logo.img"]["kind"], "mark")+ self.assertEqual(dry["spot.icon.img"]["action"], "would-refit",+ "已经是方图、只是内容太小的记重新摆位,不冒充补方")+ self.assertEqual(dry["spot.icon.img"]["kind"], "tile")self.assertEqual(dry["sign.icon.img"]["action"], "would-plate")self.assertEqual(dry["sign.icon.img"]["kind"], "vector")self.assertEqual(dry["vector.img"]["action"], "vector",@@ -1056,6 +1168,7 @@ class OperationalScriptTests(unittest.TestCase):module.normalize(root, apply=True, backup_dir=backup)}self.assertEqual(applied["wide.img"]["action"], "padded")self.assertEqual(applied["sign.logo.img"]["action"], "baked")+ self.assertEqual(applied["spot.icon.img"]["action"], "refitted")self.assertEqual(applied["sign.icon.img"]["action"], "plated")self.assertEqual((backup / "sign.icon.img").read_bytes(),originals["sign.icon.img"])@@ -1078,6 +1191,7 @@ class OperationalScriptTests(unittest.TestCase):self.assertNotIn("A", plate.getbands(), "烤过的文件必须不透明")for name, action in (("wide.img", "pad-to-square"),+ ("spot.icon.img", "refit-plate"),("sign.logo.img", "bake-white-plate"),("sign.icon.img", "plate-vector")):sidecar = json.loads(@@ -1097,6 +1211,66 @@ class OperationalScriptTests(unittest.TestCase):self.assertEqual([row["action"] for row in module.normalize(root)],["vector"])+ def test_normalising_again_takes_the_backup_original_as_its_input(self):+ """已归一的文件重跑时输入取边车记的备份原图。++ 烤底会毁掉透明通道,配错的底色在产物上再也判不回来。从原图重来,算法的+ 改进才能落到已经装好的文件上;边车继续指向原图,别把指针改指到这一轮备份+ 的归一产物。备份不在本机时只能拿现装的文件当输入。+ """+ from PIL import Image++ module = load_script("normalize_studio_logos")++ def png(image):+ buffer = io.BytesIO()+ image.save(buffer, "PNG")+ return buffer.getvalue()++ strokes = Image.new("RGBA", (200, 60), (0, 0, 0, 0))+ for x in list(range(20, 80)) + list(range(120, 180)):+ for y in range(10, 50):+ strokes.putpixel((x, y), (255, 255, 255, 255))+ original = png(strokes)+ swallowed = Image.new("RGB", (211, 211), (255, 255, 255))+ swallowed.paste(strokes.convert("RGB"), (5, 75), strokes)++ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp).resolve() / "logos"+ archive = Path(tmp).resolve() / "archive"+ backup = Path(tmp).resolve() / "backup"+ root.mkdir()+ archive.mkdir()+ (archive / "sign.img").write_bytes(original)+ installed = png(swallowed)+ (root / "sign.img").write_bytes(installed)+ Path(f'{root / "sign.img"}.ct').write_text("image/png", encoding="utf-8")+ Path(f'{root / "sign.img"}.normalization.json').write_text(json.dumps({+ "action": "bake-white-plate", "kind": "mark",+ "backup": str(archive / "sign.img"),+ }), encoding="utf-8")++ applied = {str(row["file"]): row for row in+ module.normalize(root, apply=True, backup_dir=backup)}+ self.assertEqual(applied["sign.img"]["action"], "baked")+ self.assertEqual(applied["sign.img"]["backup"], str(archive / "sign.img"))+ self.assertEqual(applied["sign.img"]["before_sha256"],+ hashlib.sha256(installed).hexdigest(),+ "复核件上的 before 是被替换掉的那个文件")+ with Image.open(root / "sign.img") as plate:+ self.assertEqual(plate.convert("RGB").getpixel((2, 2)), (17, 17, 17),+ "从原图重来才判得出白笔画该配深底")+ sidecar = json.loads(Path(f'{root / "sign.img"}.normalization.json')+ .read_text(encoding="utf-8"))+ self.assertEqual(sidecar["backup"], str(archive / "sign.img"),+ "边车继续指向原图")+ self.assertEqual(sidecar["original_sha256"],+ hashlib.sha256(original).hexdigest())+ self.assertEqual((backup / "sign.img").read_bytes(), installed,+ "这一轮换掉的文件也留一份")+ self.assertEqual([row["action"] for row in module.normalize(root)], [],+ "原图再走一遍还是同一个产物,归一是幂等的")+def test_frame_retry_is_reserved_for_bad_color_metadata(self):"""坏色彩元数据才重试。无条件重试会让网盘超时的文件每帧白跑两次 45 秒。"""sheets = self.sheets