Working with TexFace in Python

Hello all,
As part of a fairly antiquated workflow I deal with a lot of models that user per-face UV image assignments, or “TexFace” in Blender terms. I’m trying to figure out a way to find the assigned image for a given face. Eventually I want to be able to iterate through all the faces of a mesh and do things to them based on which images are assigned, but so far I haven’t been able to find how to access that information. I’m using Blender 2.79.

I’m a bit embarrassed because this seems like it ought to be easy, but it’s got me stuck.

TL;DR: How can one make a script that returns the name of the assigned TexFace image for the selected face(s)?

Found it. For future reference, here is the solution:

import bpy

object = bpy.context.object
mesh =

for face in mesh.uv_textures['UVMap'].data: