I need to get Pixel coordinates of an image. Here is explanation: enter image description here

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.

  • $\begingroup$ Can you elaborate on what your workflow is going to look like. Are you importing external images first? $\endgroup$ Commented May 31, 2016 at 1:10
  • $\begingroup$ @ToddMcIntosh yes, I just load image from file system. I am creating a tool that will add and move objects on image. For this I need to get coordinates of mouse pointer on image. $\endgroup$ Commented May 31, 2016 at 6:34

1 Answer 1


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]

You must log in to answer this question.

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