Python: How to Bulk Load Image Textures in Blender

The imageLoad Function

I have an obsession with timelines, which honestly may be bordering on manic and unhealthy. A 3D timeline has been on my back-burner for months because while I have written a function that auto-creates materials in Python, I had not yet mastered the art of applying image textures to those materials.

That’s today’s project.

The imageLoad Function

This function looks at all the .jpg’s in a folder, creates a plane for each one, and maps the image onto it. Here’s the folder with images I’ve compiled.

Image Files

Note that before running the function, you’ll need to set Blender to the Cycles Render. If you accidentally run it with a different render engine set, you may need to restart the program to get it to stop throwing errors.

Cycles Render

The function takes one parameter—the file path of the folder that contains the .jpg’s. Blender materials can’t have wildly long names, so the function takes the names of those files and slices them down to 20 characters.

As written, it places the planes along the z axis separated in 5 blender unit intervals.

Here’s a more intense breakdown of how it works:

The imageLoad Function

After it’s run, you should see this cool line-up of images ready to go.


A copy/paste version of this code is available at this gist.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: