From 14a2c755d6b4488c8572dcfa5d64f673fae9cedc Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 23 Oct 2026 11:57:21 +0200 Subject: companion: frames.txt, gen-frames and prep-frames The frames are a list now, not a session in the web UI: frames.txt holds one line per frame (output, the image klein edits, the prompt, with shared sentences as variables), and gen-frames makes the missing ones, or the ones named, through the running sd-server's job API (/sdcpp/v1/img_gen, polled at /sdcpp/v1/jobs/). sd-cli would reload the model for every frame. Adding or changing a frame is an edit and a rerun; --seed rerolls one. Then prep-frames cuts each out of its white background at one common scale. Checked on dress/smile: about 2 minutes a frame on klein, pose and outfit kept. The art stays outside the repo, in ~/.local/share/keystone/companion. Co-Authored-By: Claude Opus 5.5 --- desktop/companion/prep-frames | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 desktop/companion/prep-frames (limited to 'desktop/companion/prep-frames') diff --git a/desktop/companion/prep-frames b/desktop/companion/prep-frames new file mode 100755 index 0000000..462657e --- /dev/null +++ b/desktop/companion/prep-frames @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Copyright (C) 2026 Danilo M. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# prep-frames: the companion's generated images to the frames she shows. +# +# prep-frames [ART_DIR] default: ~/.local/share/keystone/companion/2b +# +# Reads ART_DIR/dress/*.png and ART_DIR/leotard/*.png, 1024x1024 on white, +# and writes ART_DIR/frames//.png: background removed, trimmed +# to her, scaled by a quarter. One scale for every frame keeps her the same +# size whatever the pose, which scaling each to a fixed height would not: +# lying down would come out huge. Sprite.qml draws them at half size and +# stands each on its bottom edge. +# +# The background goes by flood fill from the four corners: the dark line art +# stops the fill, so the white hair and the white leotard inside it stay. + +set -euo pipefail + +art=${1:-$HOME/.local/share/keystone/companion/2b} +n=0 +for outfit in dress leotard; do + [[ -d $art/$outfit ]] || continue + mkdir -p "$art/frames/$outfit" + for src in "$art/$outfit"/*.png; do + [[ -e $src ]] || continue + read -r w h < <(magick identify -format '%w %h\n' "$src") + magick "$src" -alpha set -fuzz 6% -fill none \ + -draw "color 0,0 floodfill" -draw "color $((w - 1)),0 floodfill" \ + -draw "color 0,$((h - 1)) floodfill" -draw "color $((w - 1)),$((h - 1)) floodfill" \ + -trim +repage -resize 25% "$art/frames/$outfit/$(basename "$src")" + n=$((n + 1)) + done +done +echo "prep-frames: $n frames in $art/frames" -- cgit v1.2.3