====== Differences ====== This shows you the differences between two versions of the page.
| images_proxies_blender_script [2015/08/07 08:49] flavio created | images_proxies_blender_script [2015/08/19 14:06] (current) damien syntax highlighting | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| For scenes with huge textures, the first part will make a smaller version of the image and save it as proxy (updating textures paths); the second part of the script will re-assign the original paths to the textures to load the big images. | For scenes with huge textures, the first part will make a smaller version of the image and save it as proxy (updating textures paths); the second part of the script will re-assign the original paths to the textures to load the big images. | ||
| - | import bpy | + | <code python>import bpy | 
| - | + | ||
| - | + | ||
| - | #PROXY | + | |
| - | for obj in bpy.context.selected_objects: | + | |
| - | img = obj.active_material.active_texture.image | + | |
| - | img.reload() | + | |
| - | img_copy = img.copy() | + | |
| - | img_copy.name = img.name + "_orig" | + | |
| - | img.scale(img.size[0]*0.2, img.size[1]*0.2) | + | |
| - | path = bpy.path.abspath('//'+img.name.split(".")[0]+"_proxy.png") | + | |
| - | img.save_render(path) | + | |
| - | + | ||
| - | img.filepath = img.filepath.split(".")[0] + "_proxy.png" | + | |
| - | img.reload() | + | |
| - | + | ||
| - | ##DEPROXY | + | |
| - | for obj in bpy.context.selected_objects: | + | |
| - | tex = obj.active_material.active_texture | + | |
| - | img = tex.image.name | + | |
| - | print(img) | + | |
| - | orig_img = bpy.data.images[img+"_orig"] | + | |
| - | tex.image = orig_img | + | |
| + | #PROXY | ||
| + | for obj in bpy.context.selected_objects: | ||
| + | img = obj.active_material.active_texture.image | ||
| + | img.reload() | ||
| + | img_copy = img.copy() | ||
| + | img_copy.name = img.name + "_orig" | ||
| + | img.scale(img.size[0]*0.2, img.size[1]*0.2) | ||
| + | path = bpy.path.abspath('//'+img.name.split(".")[0]+"_proxy.png") | ||
| + | img.save_render(path) | ||
| + | |||
| + | img.filepath = img.filepath.split(".")[0] + "_proxy.png" | ||
| + | img.reload() | ||
| + |  | ||
| + | ##DEPROXY | ||
| + | for obj in bpy.context.selected_objects: | ||
| + | tex = obj.active_material.active_texture | ||
| + | img = tex.image.name | ||
| + | print(img) | ||
| + | orig_img = bpy.data.images[img+"_orig"] | ||
| + | tex.image = orig_img | ||
| + | </code> | ||