It seems to be easy but as a beginner, I can not configure it.

I have four blocks with different images. I add all four images using Images as Planes. Now I want to replace all four images with different images running script.

enter image description here

  • $\begingroup$ Do you want switch the image in the material node or change the material? $\endgroup$
    – X Y
    Commented May 1, 2022 at 17:36
  • $\begingroup$ @XY Sir, I want to replace the image with a new one every time so I think changing the material will be a good option. Any other solution will be highly appreciated. $\endgroup$
    – SAHU
    Commented May 2, 2022 at 2:55
  • $\begingroup$ here is the ans to change material of a object: blender.stackexchange.com/questions/53366/… $\endgroup$
    – X Y
    Commented May 2, 2022 at 3:08
  • $\begingroup$ @X Y Thanks, sir. I got the idea of how to change images with changing material. But it will be a huge help if you give some idea how to change images using material node. $\endgroup$
    – SAHU
    Commented May 2, 2022 at 5:46

2 Answers 2


Change Image Texture image

import bpy

mats    = bpy.data.materials    # all materials store in here

mat     = mats["your Material"]      # get a material

tree    = mat.node_tree         # get node tree of the material

nodes   = tree.nodes            # all nodes in node_tree

for node in nodes:
    if node.type == "TEX_IMAGE":

node    = nodes["Image Texture"]    # get node by name of node

imgs    = bpy.data.images           # all image in blend file

img     = imgs["your img name"]     # get a image

node.image = img                    # change image in node

# node.image = None                 # change image to None
  • $\begingroup$ Thanks, sir to provide me with such valuable information. $\endgroup$
    – SAHU
    Commented May 2, 2022 at 15:21

I suggest you try to use a video texture. if you encode with ffmpeg video and choose the webm encoder and setup trasnparency in the film render setting, the video can have transparency.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .