aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/companion/prep-frames
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-23 11:57:21 +0200
committerDanilo M. <danix@danix.xyz>2026-10-23 11:57:21 +0200
commit14a2c755d6b4488c8572dcfa5d64f673fae9cedc (patch)
treee7c67b58243bd8c836779ec3f8e42a11c7eb6291 /desktop/companion/prep-frames
parent96752d5c09a08991ef6efe80dafbeab98ca32321 (diff)
downloadquickshell-14a2c755d6b4488c8572dcfa5d64f673fae9cedc.tar.gz
quickshell-14a2c755d6b4488c8572dcfa5d64f673fae9cedc.zip
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/<id>). 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 <noreply@anthropic.com>
Diffstat (limited to 'desktop/companion/prep-frames')
-rwxr-xr-xdesktop/companion/prep-frames45
1 files changed, 45 insertions, 0 deletions
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. <danix@danix.xyz>
+#
+# 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/<outfit>/<name>.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"