netrender: refactor thumbnail generation code. New option to generate the thumbnail on the slaves (per slave option, default off). Missing thumbnails are still generated on demand by the master.

This commit is contained in:
2010-01-09 18:21:27 +00:00
parent e3641796c2
commit 670d55f097
5 changed files with 131 additions and 35 deletions

View File

@@ -28,7 +28,7 @@ try:
except:
bpy = None
VERSION = bytes("0.7", encoding='utf8')
VERSION = bytes("0.8", encoding='utf8')
# Jobs status
JOB_WAITING = 0 # before all data has been entered
@@ -172,3 +172,28 @@ def prefixPath(prefix_directory, file_path, prefix_path):
full_path = prefix_directory + file_path
return full_path
def thumbnail(filename):
root = os.path.splitext(filename)[0]
imagename = os.path.split(filename)[1]
thumbname = root + ".jpg"
if os.path.exists(thumbname):
return thumbname
if bpy:
sce = bpy.data.scenes[0]
sce.render_data.file_format = "JPEG"
sce.render_data.quality = 90
bpy.ops.image.open(path = filename)
img = bpy.data.images[imagename]
img.save(thumbname, scene = sce)
try:
process = subprocess.Popen(["convert", thumbname, "-resize", "300x300", thumbname])
process.wait()
return thumbname
except:
pass
return None