Sometimes it is easier to make assumptions about data that you are going to operate on with a script. Like, for instance. All my images are going to reside in the same folder. PKHG’s solution will certainly work, but what happens when you are finished with your scene and archive time comes around? I have found that it is better to simply gather up your footage/stills into a working folder for any given project. That way if you need to transfer the scene to another computer for rendering, for instance, you have all the assets in one place.
Here is some code I used to load images.
def returnImageTexture (passedFileName):
tempTexture = Texture.New()
try:
tempImage = Image.Load(passedFileName)
tempTexture.setType('Image')
tempTexture.animFrames = 3140
tempTexture.image = tempImage
print ("Loaded image texture [" + passedFileName + "].")
except:
tempImage = None
tempTexture.setType('None')
print ("Unable to load image texture [" + passedFileName + "].")
return tempImage, tempTexture
#Code Execution begins here.
localScene = Scene.GetCurrent()
Blender.Noise.setRandomSeed(0)
# This default material will be applied to all other sides of the cube (ie not video face)
matDefault = Blender.Material.New('cubeDefault')
matDefault.rgbCol = 1,0,0
imagePath = 'C:\\Documents and Settings\Developer\\My Documents\\Blender\\scenes\ extures\\'
#Load the images we are going to use.
matImage1 = Blender.Material.New('cubeImage1')
matImage1.rgbCol = 0,0,1
fileName1 = imagePath + 'image-1.jpg'
myImage1, myTex1 = returnImageTexture(fileName1)
matImage1.setTexture(0, myTex1,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To
matImage2 = Blender.Material.New('cubeImage2')
matImage2.rgbCol = 0,1,0
fileName2 = imagePath + 'image-2.jpg'
myImage2, myTex2 = returnImageTexture(fileName2)
matImage2.setTexture(0, myTex2,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To
matImage3 = Blender.Material.New('cubeImage3')
matImage3.rgbCol = 1,1,0
fileName3 = imagePath + 'image-3.jpg'
myImage3, myTex3 = returnImageTexture(fileName3)
matImage3.setTexture(0, myTex3,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To
matImage4 = Blender.Material.New('cubeImage4')
matImage4.rgbCol = 0,0.5,0
fileName4 = imagePath + 'image-4.jpg'
myImage4, myTex4 = returnImageTexture(fileName4)
matImage4.setTexture(0, myTex4,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To
matImage5 = Blender.Material.New('cubeImage5')
matImage5.rgbCol = 0.5,0.5,0
fileName5 = imagePath + 'image-5.jpg'
myImage5, myTex5 = returnImageTexture(fileName5)
matImage5.setTexture(0, myTex5,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To
matImage6 = Blender.Material.New('cubeImage6')
matImage6.rgbCol = 0,0,0.5
fileName6 = imagePath + 'image-6.jpg'
myImage6, myTex6 = returnImageTexture(fileName6)
matImage6.setTexture(0, myTex6,Texture.TexCo.UV,Texture.MapTo.COL) #Texture Channel, The Texture,Map Input, Map To