-
Notifications
You must be signed in to change notification settings - Fork 2
/
gimp_ani.sh
executable file
·51 lines (40 loc) · 1.54 KB
/
gimp_ani.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /usr/bin/env bash
# Signature
# scene_name windows_name delay hotx hoty
scene_name=$1
windows_name=$2
delay=$3
hotx=$4
hoty=$5
images=(./working/$1/frames/*.png)
first=${images[0]}
unset images[0]
pycode="
try:
img = Gimp.list_images()[0]
loaded_layers = [Gimp.file_load_layer(1, img, Gio.file_new_for_path(i)) for i in '${images[@]}'.split(' ')]
for lay in loaded_layers:
img.insert_layer(lay, None, 0)
layers = img.list_layers()
size = len(layers)
c = Gimp.get_pdb().lookup_procedure('file-ani-save').create_config()
c.set_property('image', img)
c.set_property('file', Gio.file_new_for_path('./icons/nier_cursors_windows/$windows_name.ani'))
c.set_property('drawables', Gimp.ObjectArray.new(Gimp.Drawable, layers, False))
c.set_property('num-drawables', size)
c.set_property('author-name', 'Beinsezii')
c.set_property('cursor-name', 'NieR_$name')
c.set_property('default-delay', $delay)
c.set_property('n-hot-spot-x', size)
c.set_property('n-hot-spot-y', size)
# TODO figure out how to construct a Gimp.Int32Array
# has no constructor
# doesn't like python lists, Gimp.Array, or Gimp.ValueArray
# the fuck do I do. introspection why you do dis
# c.set_property('hot-spot-x', [$hotx] * size)
# c.set_property('hot-spot-y', [$hoty] * size)
Gimp.get_pdb().run_procedure_config('file-ani-save', c)
except Exception as e:
print(f'BEGIN_GIMP_ANI_ERROR\n\n\n{e}\n\n\nEND_GIMP_ANI_ERROR')
"
gimp-2.99 --batch-interpreter python-fu-eval --quit -idfb "$pycode" $first