This could be interesting for some of you, so below I present a demo code which scans all the faces in the current mesh:
import bpy
# Let's use the current cube
mesh = bpy.data.meshes["Cube"]
# make sure we are in the object mode
bpy.ops.object.mode_set(mode='OBJECT')
for i, face in enumerate(mesh.faces):
uf = mesh.uv_textures.active.data[i]
img = uf.image
print ("image = " + str(uf.image.name))
two = uf.use_twoside
print ("two_side = " + str(two))
The key is to use uv_textures.active.data[i] and go through all the faces by incrementing variable i. There’s also one very important part - the script needs to go into object mode to perform this operation. That’s why I included the line which switches to object mode.