Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2020 10:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Replaces a texture png with given command line input
# Run as: blender -b <filename> -P <this_script> -- <image_path>
# Example: blender -b myfile.blend -P -- new_texture.png
import bpy, sys, os
# Assume the last argument is image path
imagePath = bpy.path.abspath(os.path.join(os.getcwd(), sys.argv[-1]))
if not os.path.exists(imagePath):
print("Image not found:", imagePath)
# Change the image data block name to match your blender file['foil.png'].filepath = imagePath
# Render to separate file, identified by texture file
imageBaseName = bpy.path.basename(imagePath)
bpy.context.scene.render.filepath = os.path.join(os.getcwd(), 'render-' + imageBaseName)
# Render still image, automatically write to output path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment