Pixel Coordinates of Image with Python I need to get Pixel coordinates of an image. Here is explanation:


In the Image Editor, I can see the coordinates in the bottom left corner by clicking on the image. Is it possible to get the coordinates with Python? Solution for this question Pixel Coordinates of Rendered Image with Python doesn't help, because it works only for rendered image and I need this for any image.
Eeeeeeh… that answer sounds horribly complicated to me!

Assuming you are getting mouse coordinates from event e (from invoke or modal callbacks of an operator), and assuming that operator runs into the main ('WINDOW' type) region of the UVEditor space, something like that should work (code not tested):

region = C.region
reg_x, reg_y = e.mouse_region_x, e.mouse_region_y
img_size = C.space.image.size

uv_x, uv_y = region.view2d.region_to_view(reg_x, reg_y)

img_x, img_y = uv_x * img_size[0], uvèy * img_size[1]