How can I find out the name of a texture linked to an object?

Is there an image operator to find this out?

I searched in forums but wasn't able to find a working script, I tried this script:

import Blender
from Blender import*
img = ''
sel = bpy.context.object.name
if sel:
me = sel[0].getData(mesh=True)
for f in me.faces:
    if f.image:
        img = f.image.name
        print (img)

But the code doesn't work in my python console with Blender 2.68.

How could we find what are all the images in an object and its name and path?

  • 4
    $\begingroup$ This code is quite ancient (pre - blender 2.5). The Blender module does not exist anymore and we use the bpy module now for data access. $\endgroup$ Nov 26, 2013 at 14:13

3 Answers 3


This is a more direct version of the original script.

import bpy

obj = bpy.context.object
if obj:
    me = obj.data
    if me.uv_textures.active is not None:
        for tf in me.uv_textures.active.data:
            if tf.image:
                img = tf.image.name

Note that you now need to access the face's image though the uv_textures data-layer, in this case we assume one exists and choose the active one. me.uv_textures["UVTex.001"].data would work too if its present.

  • $\begingroup$ What is the up to date equivalent of that functionality? $\endgroup$
    – pbn
    Jan 11, 2019 at 16:21

This script will iterate over all objects and print texture names and image name when available, try the dump() method to find out more on attributes you are interested in. e.g. dump(mtex_slot)

import bpy

def dump(obj):
   for attr in dir(obj):
       if hasattr(obj, attr):
           print("obj.%s = %r" % (attr, getattr(obj, attr)))


for ob in bpy.data.objects:
    for mat_slot in ob.material_slots:
        for mtex_slot in mat_slot.material.texture_slots:
            if mtex_slot:
                # dump(mtex_slot)
                print("\t%s" % mtex_slot)
                if hasattr(mtex_slot.texture , 'image'):
                    print("\t\t%s" % mtex_slot.texture.image.filepath)
  • 1
    $\begingroup$ This script access material images, the script in the question is asking about uv-texture images (still useful, but added own answer). $\endgroup$
    – ideasman42
    Nov 26, 2013 at 20:06

From the above two answer I got and This is code I desired to bring out. . . Thanks...This tells the Image name and its path.

ob = bpy.context.object
if ob:
 for mat_slot in ob.material_slots:
     for mtex_slot in mat_slot.material.texture_slots:
         if mtex_slot:
                 if hasattr(mtex_slot.texture , 'image'):
                 print("\t\t%s" % mtex_slot.texture.image.filepath)



mtex_slot.texture --> to get Texture name

mtex_slot.texture.image --> to get Image name

mtex_slot.texture.image.filepath --> to get path and Image name


You must log in to answer this question.

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