Skip to content

Instantly share code, notes, and snippets.

@Alquimista
Created August 22, 2011 18:25
Show Gist options
  • Save Alquimista/1163097 to your computer and use it in GitHub Desktop.
Save Alquimista/1163097 to your computer and use it in GitHub Desktop.
def get_pixel_colour(i_x, i_y):
import PIL.Image # python-imaging
import PIL.ImageStat # python-imaging
import Xlib.display # python-xlib
o_x_root = Xlib.display.Display().screen().root
o_x_image = o_x_root.get_image(i_x, i_y, 1, 1, Xlib.X.ZPixmap, 0xffffffff)
o_pil_image_rgb = PIL.Image.fromstring("RGB", (1, 1), o_x_image.data, "raw", "BGRX")
lf_colour = PIL.ImageStat.Stat(o_pil_image_rgb).mean
return tuple(map(int, lf_colour))
print get_pixel_colour(0, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment