Skip to content

Commit 09616b7

Browse files
committed
Merge pull request #5 from agoose77/patch-1
Update spritify.py with patch from agoose77
2 parents 59cf416 + d7575e8 commit 09616b7

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

spritify.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ class SpriteSheetProperties(bpy.types.PropertyGroup):
8181
description = "Automatically create an animated GIF when rendering is complete",
8282
default = True)
8383

84+
85+
def find_bin_path_windows():
86+
import winreg
87+
88+
REG_PATH = "SOFTWARE\ImageMagick\Current"
89+
90+
try:
91+
registry_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, REG_PATH, 0,
92+
winreg.KEY_READ)
93+
value, regtype = winreg.QueryValueEx(registry_key, "BinPath")
94+
winreg.CloseKey(registry_key)
95+
96+
except WindowsError:
97+
return None
98+
99+
return value
100+
84101

85102
@persistent
86103
def spritify(scene):
@@ -118,8 +135,16 @@ def gifify(scene):
118135
if os.path.exists(bpy.path.abspath(scene.spritesheet.filepath[:-3] + "gif")):
119136
os.remove(bpy.path.abspath(scene.spritesheet.filepath[:-3] + "gif"))
120137

138+
# If windows, try and find binary
139+
convert_path = "convert"
140+
if os.name == "nt":
141+
bin_path = find_bin_path_windows()
142+
143+
if bin_path:
144+
convert_path = os.path.join(bin_path, "convert")
145+
121146
subprocess.call([
122-
"convert",
147+
convert_path,
123148
"-delay", "1x" + str(scene.render.fps),
124149
"-dispose", "background",
125150
"-loop", "0",

0 commit comments

Comments
 (0)