# How do I get the image index that matches the material texture? I see that the index order changes depending on the image name

I have used a small script that Atom had published online, and it uses the index 0 for the image editor to then get the sizes of the image for setting render resolution. That art works great until you have more images loaded in blender, and then the index order may have changed. I want to get the index that matches the selected object's texture so that the operation doesn't mess up and use the wrong pixel resolution.

Any ideas here?

image_index = 0

    rnd = bpy.data.scenes[0].render
rnd.resolution_x, rnd.resolution_y = bpy.data.images[image_index].size[:]


import bpy