It seems that gpu.texture.from_image(image) only accepts bpy.types.Image datablock. I was wondering if there is any way to use bpy.types.ImagePreview instead? https://docs.blender.org/api/current/bpy.types.ImagePreview.html#bpy.types.ImagePreview

Basically looking to combine the 2D image drawing from here https://docs.blender.org/api/current/gpu.html#d-image with the batch image preview loading from the Python Template: UI Previews Dynamic Enum in the blender Text Editor.

I want to load a whole folder of images and display them on screen with GPU, but I don't like that the images are visible in Outliner > Blend File > Images. Also bpy.utils.previews seems like it's designed for managing many images, but is it the case that these images are only accessible with UILayout, not GPU? https://docs.blender.org/api/current/bpy.utils.previews.html#module-bpy.utils.previews


1 Answer 1


Nothing in the docs about using bpy.types.ImagePreview for GPU textures, so I don't think you can do that.

But you don't have to keep the images once you have created the GPU textures. That approach can give you a clean Images list.

import bpy
import gpu

# Your images
image_files = ['//images/image_1.png']

# GPU textures
textures = []

# Create textures
for img_file in image_files:
    # Load image
    img = bpy.data.images.load(img_file)

    # Create GPU texture
    # (see https://docs.blender.org/api/current/gpu.html#d-image)

    # Remove image, so it won't show in the Image list in the UI

# And use 'textures' in your GPU draw function...

You must log in to answer this question.

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