aboutsummaryrefslogtreecommitdiff
path: root/mkpetscmd
diff options
context:
space:
mode:
Diffstat (limited to 'mkpetscmd')
-rwxr-xr-xmkpetscmd43
1 files changed, 43 insertions, 0 deletions
diff --git a/mkpetscmd b/mkpetscmd
new file mode 100755
index 00000000..5a6eeb5f
--- /dev/null
+++ b/mkpetscmd
@@ -0,0 +1,43 @@
+#!/usr/bin/env lua
+
+local input = arg[1] or "$1"
+local output = arg[2] or "$2"
+
+local squish = 1.25
+local scale = 0.875
+local delay = 60
+local flip = false
+
+local sprite = { x = 14, y = 20, w = 112, h = 112 }
+local frames = {
+ { x = 0, y = 0, w = 0, h = 0 },
+ { x = -4, y = 12, w = 4, h = -12 },
+ { x = -12, y = 18, w = 12, h = -18 },
+ { x = -8, y = 12, w = 4, h = -12 },
+ { x = -4, y = 0, w = 0, h = 0 },
+}
+local hand = { w = 112, h = 112 }
+
+local cmd = {}
+for i, f in ipairs(frames) do
+ local x, y, w, h =
+ math.floor(sprite.x + f.x * squish * 0.4),
+ math.floor(sprite.y + f.y * squish * 0.9),
+ math.floor((sprite.w + f.w * squish) * scale),
+ math.floor((sprite.h + f.h * squish) * scale)
+ local hand_y = math.max(0, math.floor(y * 0.75 - math.max(0, sprite.y) - 0.5))
+ table.insert(cmd,
+ ("\tmagick -size %dx%d xc:transparent"
+ .." \\( \"%s\" %s -resize %dx%d! -geometry +%d+%d \\) -composite"
+ .." \\( hand.png -crop %dx%d+%d+%d -geometry +%d+%d \\) -composite"
+ .." -depth 8 rgba:-\n")
+ :format(sprite.w, sprite.h,
+ input, flip and "-flop" or "", w, h, x, y,
+ hand.w, hand.h, (i-1)*hand.w, 0, 0, hand_y))
+end
+
+print(
+ ("(\n%s) | ffmpeg -hide_banner -loglevel error"
+ .." -f rawvideo -pixel_format rgba -video_size %dx%d -framerate %f -i -"
+ .." -f gif -filter_complex 'split[v],palettegen,[v]paletteuse' -y \"%s\"")
+ :format(table.concat(cmd), sprite.w, sprite.h, 1000/delay, output))