I am currently a non-user of Blender, not having used it for about six years.

I have the need to wrap a number of large number of images around a sphere and produce a 3d render (poss with or without the sphere being rendered to help in composite work).

Can Blender be automated to iterate over a number of images, apply an image with the same mapping coords, and then produce a render?


If you have a scene set up with your camera in position, and a sphere that's been UV mapped, has a material applied with an Image Texture connected and setting the color, you can use this script to automate loading images and rendering the results:

import bpy
from os import listdir
from os.path import join, dirname

s = bpy.data.objects['Sphere']  # <-- REPLACE OBJECT NAME IF NEEDED
m = s.active_material
t = m.texture_slots[0].texture

img = t.image

imagesFolder = "C:/SomeFolderWithImges"  # <-- REPLACE THIS WITH ACTUAL PATH TO YOUR IMAGES

isImage = lambda fp: fp.endswith( tuple( bpy.path.extensions_image ) )

for f in listdir(imagesFolder):
    if isImage( f ):
        t.image.filepath = join( imagesFolder, f )
        bpy.context.scene.render.filepath = join( dirname( bpy.context.scene.render.filepath ), f )
        bpy.ops.render.render( write_still = True )

Just copy this into a new textfile in the text editor, replace the path to the images you want to map to your sphere on line 11, and press Run Script.

Sample scene initial setup: Scene initial setup

Rendered results after running script: enter image description here

| improve this answer | |
  • $\begingroup$ Wow, great answer! As an aside, is it possible to composite in Blender as a single frame image. I'm thinking of setting up a scene and then changing textures, and this would save having to manually composite with other means. $\endgroup$ – user3791372 Nov 25 '15 at 23:21
  • 1
    $\begingroup$ Sure, you can create compositor node setups as well using the python API. Here's some places to start: blender.stackexchange.com/questions/23436/… and also: blender.stackexchange.com/questions/5413/… $\endgroup$ – TLousky Nov 25 '15 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.