包含三个子项目: - avatar-h5-renderer: Live2D Cubism 4 H5 渲染器 (Vite + TS) - avatar_flutter_app: Flutter 容器 App (打包 H5 进 WebView) - gif-export: puppeteer 导出 32 个动作的透明 GIF (供 ESP32 圆屏播放) 模型资源: Haru, Natori (含贴图、moc3、motions, expressions) 设计文档: AI驱动虚拟形象渲染方案_v5.1.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
698 B
Python
26 lines
698 B
Python
from PIL import Image
|
|
import shutil
|
|
import sys
|
|
|
|
src = "/Users/maidong/Desktop/AR测试/avatar-h5-renderer/public/Resources/Haru/Haru.2048/texture_01.png"
|
|
backup = src.replace(".png", ".backup.png")
|
|
threshold = int(sys.argv[1]) if len(sys.argv) > 1 else 30
|
|
|
|
shutil.copy2(src, backup)
|
|
print(f"backup -> {backup}")
|
|
|
|
img = Image.open(src).convert("RGBA")
|
|
pixels = img.load()
|
|
w, h = img.size
|
|
|
|
changed = 0
|
|
for y in range(h):
|
|
for x in range(w):
|
|
r, g, b, a = pixels[x, y]
|
|
if r <= threshold and g <= threshold and b <= threshold:
|
|
pixels[x, y] = (r, g, b, 0)
|
|
changed += 1
|
|
|
|
img.save(src)
|
|
print(f"size={w}x{h}, threshold<={threshold}, transparent pixels={changed}")
|