adopt_video: optional per-clip ADOPT options (tween, shade)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-14 20:37:06 +02:00
parent 3b39dbce0b
commit 052a56bc11

View File

@@ -11,11 +11,16 @@ Sidebar scenes (scene_*) are a slow loop in the game's left column instead: no
vignette and no in-between frames, but the same darkening towards the bottom the vignette and no in-between frames, but the same darkening towards the bottom the
still image had (MainForm.SceneBitmap), so it blends into the dark column. still image had (MainForm.SceneBitmap), so it blends into the dark column.
Optional per clip, ADOPT = {name: {"tween": bool, "shade": 0..255}} in the project's
VIDEO_MODULE: tween=False keeps the 49 raw frames (slow loops, half the size), shade
darkens every frame by that alpha of black (to match a dimmed backdrop in the game).
Usage: Usage:
py -3.12 adopt_video.py every clip that has frames py -3.12 adopt_video.py every clip that has frames
py -3.12 adopt_video.py story_old just one py -3.12 adopt_video.py story_old just one
""" """
import glob import glob
import importlib
import os import os
import sys import sys
@@ -26,6 +31,7 @@ from PIL import Image, ImageDraw, ImageFilter
import _bootstrap # Projektordner (config.py, Listen) vor allen anderen Modulen import _bootstrap # Projektordner (config.py, Listen) vor allen anderen Modulen
import config import config
ADOPT = getattr(importlib.import_module(getattr(config, "VIDEO_MODULE", "video_life")), "ADOPT", {})
SRC = os.path.join(config.OUTPUT_DIR, "video") SRC = os.path.join(config.OUTPUT_DIR, "video")
DEST = os.path.join(config.ASSETS_DIR, "Video") DEST = os.path.join(config.ASSETS_DIR, "Video")
QUALITY = 80 QUALITY = 80
@@ -82,7 +88,8 @@ def adopt(name):
os.remove(old) os.remove(old)
raw = [np.asarray(Image.open(f).convert("RGB")) for f in frames] raw = [np.asarray(Image.open(f).convert("RGB")) for f in frames]
scene = name.startswith("scene_") scene = name.startswith("scene_")
if not scene: opts = ADOPT.get(name, {})
if opts.get("tween", not scene):
raw = interpolate(raw) raw = interpolate(raw)
size = (raw[0].shape[1], raw[0].shape[0]) size = (raw[0].shape[1], raw[0].shape[0])
mask = bottom_shade(size) if scene else vignette(size) mask = bottom_shade(size) if scene else vignette(size)
@@ -90,6 +97,8 @@ def adopt(name):
total = 0 total = 0
for i, arr in enumerate(raw): for i, arr in enumerate(raw):
im = Image.composite(black, Image.fromarray(arr), mask) im = Image.composite(black, Image.fromarray(arr), mask)
if opts.get("shade"):
im = Image.composite(Image.new("RGB", size, (0, 0, 0)), im, Image.new("L", size, opts["shade"]))
p = os.path.join(DEST, f"{name}_{i:02d}.jpg") p = os.path.join(DEST, f"{name}_{i:02d}.jpg")
im.save(p, quality=QUALITY, optimize=True) im.save(p, quality=QUALITY, optimize=True)
total += os.path.getsize(p) total += os.path.getsize(p)