Tool to easily select a pixel on screen and get color and absolute coordinates












18















I am looking for a tool that lets me select any pixel on the screen and get its RGB color and absolute (x, y) location.



I have used tools on Windows that show a large magnified square with a crosshair letting me easily select the pixel I want and get its details.



Is there anything like this for ubuntu?










share|improve this question























  • just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

    – snowguy
    Jul 23 '12 at 17:42











  • I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

    – Flash
    Jul 24 '12 at 23:50











  • If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

    – Anonymous
    Jul 25 '12 at 1:26











  • Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

    – snowguy
    Jul 26 '12 at 3:45
















18















I am looking for a tool that lets me select any pixel on the screen and get its RGB color and absolute (x, y) location.



I have used tools on Windows that show a large magnified square with a crosshair letting me easily select the pixel I want and get its details.



Is there anything like this for ubuntu?










share|improve this question























  • just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

    – snowguy
    Jul 23 '12 at 17:42











  • I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

    – Flash
    Jul 24 '12 at 23:50











  • If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

    – Anonymous
    Jul 25 '12 at 1:26











  • Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

    – snowguy
    Jul 26 '12 at 3:45














18












18








18


5






I am looking for a tool that lets me select any pixel on the screen and get its RGB color and absolute (x, y) location.



I have used tools on Windows that show a large magnified square with a crosshair letting me easily select the pixel I want and get its details.



Is there anything like this for ubuntu?










share|improve this question














I am looking for a tool that lets me select any pixel on the screen and get its RGB color and absolute (x, y) location.



I have used tools on Windows that show a large magnified square with a crosshair letting me easily select the pixel I want and get its details.



Is there anything like this for ubuntu?







software-recommendation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 15 '12 at 9:48









FlashFlash

148118




148118













  • just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

    – snowguy
    Jul 23 '12 at 17:42











  • I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

    – Flash
    Jul 24 '12 at 23:50











  • If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

    – Anonymous
    Jul 25 '12 at 1:26











  • Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

    – snowguy
    Jul 26 '12 at 3:45



















  • just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

    – snowguy
    Jul 23 '12 at 17:42











  • I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

    – Flash
    Jul 24 '12 at 23:50











  • If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

    – Anonymous
    Jul 25 '12 at 1:26











  • Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

    – snowguy
    Jul 26 '12 at 3:45

















just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

– snowguy
Jul 23 '12 at 17:42





just curious why you are looking for this particular combination together...that may help us think of an answer. why do you want to know the x,y coordinates and the color?

– snowguy
Jul 23 '12 at 17:42













I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

– Flash
Jul 24 '12 at 23:50





I am writing an automation tool that sends keyboard and mouse input in response to seeing certain things on the screen. Some parts depend on using x,y offsets of certain buttons etc inside a window, and I'd like an easy way to find these offsets exactly.

– Flash
Jul 24 '12 at 23:50













If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

– Anonymous
Jul 25 '12 at 1:26





If this is for the web and you're Firefox then there is a extension called ColorZilla. colorzilla.com/firefox

– Anonymous
Jul 25 '12 at 1:26













Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

– snowguy
Jul 26 '12 at 3:45





Andrew, looks like Ian B wrote a tool that does just what you want. Seems like he deserves the bounty.

– snowguy
Jul 26 '12 at 3:45










6 Answers
6






active

oldest

votes


















4





+50









The best fit is...a tiny Windows tool called ColorPix (via WINE)



After searching long and hard, it appears none of the available tools for Ubuntu/Linux fulfill both your criteria, i.e. magnification and coordinate display.



So we go for a tiny Windows tool that -- critically -- just works with a default WINE install, no configuration, installation, DLLs, etc. needed.





  • It features adjustable zoom, one-click copy in multiple formats and co-ordinate display:



    enter image description here




1. Install Wine



sudo apt-get install wine


(that's it!)



2. Download ColorPix



ColorPix can be officially downloaded as a tiny, portable 600KB exe here



I suggest downloading directly to your local binaries directory with:



sudo wget -O/usr/local/bin/ColorPix.exe http://www.colorschemer.com/ColorPix.exe


3. Create a launcher for ColorPix





  • Let's get an icon first:



    sudo wget -O/usr/share/icons/colorpix.png http://cdn.alternativeto.net/i/22e49edc-efa7-e011-979d-0025902c7e73_11865.png



  • Press Alt+F2 now and type gksudo gedit /usr/share/applications/colorpix.desktop, and paste the below and save the file:




    [Desktop Entry]
    Name=ColorPix
    GenericName=ColorPix
    Comment=ColorPicker via WINE
    Exec=wine /usr/local/bin/ColorPix.exe
    Terminal=false
    Icon=/usr/share/icons/colorpix.png
    Type=Application
    StartupNotify=true



  • From a terminal, run:



    sudo chmod +x /usr/share/applications/colorpix.desktop



  • In a few seconds, it will be available in the launcher as:



    enter image description here




4. Using ColorPix



Start it, and the very first time it may take a few seconds while WINE initializes.



The screenshot below shows it in action, with:




  • The coordinates on the top

  • Color values in different formats below (click to copy to clipboard)

  • Adjustable magnifier below


  • Press any key once you are on your desired pixel to lock values



    enter image description here








share|improve this answer
























  • Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

    – nealmcb
    Mar 2 '15 at 17:35













  • Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

    – hackerb9
    Nov 15 '18 at 16:05



















12














There is a tool called gpick.



Here you can see an image of the tool. With gpick you can select pixels, see the HTML code, add colors to the palette and generate colors.



To use it, right click the middle of the hexagon then use space bar to save colors into the palette.



gpick






share|improve this answer


























  • Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

    – Flash
    Jul 15 '12 at 12:14











  • Could you also mark this question as completed?

    – slashcrack
    Jul 15 '12 at 12:19











  • No - as I still don't have the answer :)

    – Flash
    Jul 22 '12 at 4:01











  • gpick looks great, just do sudo apt-get install gpick to install it

    – Bloke
    Oct 1 '15 at 15:54





















6














This will get you what you want I believe. Admittedly it is a few steps but it looks worse than it is since I showed each little step.



Setup



Install ImageMagick & Shutter.



sudo apt-get install imagemagick shutter


How to get the x,y coordinates and color



A. Open Shutter and click the selection button



pic of clicking selection button



B. Note that as you move your mouse around it will show you the x,y coordinates you are looking for.



enter image description here



When you've got the right place go ahead and click with your mouse button and draw a square to capture an image. (It doesn't really matter how large your image is just so long as you start it (top left corner) on the pixel of interest.)



enter image description here



C. Close the image in shutter



enter image description here



D. Run the following command from the terminal. This will give you the color values of the top left pixel.



convert ~/Pictures/Selection_001.png -crop 1x1+1+1 txt:- | sed -n 's/.* (#.*)/1/p' 


E. While in the command line go ahead and delete the image so that the next time shutter takes a picture it gives it the same name. (Otherwise you'll need to adjust the name in the previous step (D).



rm ~/Pictures/Selection_001.png





share|improve this answer
























  • Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Jan 21 '17 at 12:20



















6














Paste this code into a text editor, make it executable and run it. When you choose a color with the eyedropper, the x and y coordinates will appear at the top.



Edit: Wrote code to add a zoom window. To have it grab pixels outside of the window click the button (not the eyedropper). Click the button again to stop grabbing the pointer. Haven’t figured out how to draw a crosshair with cairo, but you can probably use as is. I left some cairo code in there in case someone can tell me why my rectangle doesn’t draw…



#!/usr/bin/python
from gi.repository import Gtk,Gdk, GdkPixbuf
import cairo

class picker(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
self.connect('motion-notify-event', self.motion_cb)
self.connect('button-press-event',self.button_press)
box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

#Setup area for coordinates and zoom window
coordbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.xcoor=Gtk.Label("x: ")
coordbox.pack_start(self.xcoor, True, False, 1)
self.ycoor=Gtk.Label("y: ")
coordbox.pack_start(self.ycoor, True, False, 1)
self.zoomwin=Gtk.Image()
#Trying to draw on Gtk.Image with cairo for crosshairs... Not working
self.zoomwin.connect('draw', self.draw)
self.zoomwin.set_app_paintable(True)
coordbox.pack_start(self.zoomwin,True,True,1)
self.buttongo=Gtk.Button("Pick Color")
self.buttongo.connect('clicked',self.gobutton_activate)
coordbox.pack_start(self.buttongo,True,True,1)
box.pack_start(coordbox, True, False, 5)

#Put in color wheel for tweaking color
self.cp=Gtk.ColorSelection()
self.cp.connect('color-changed', self.on_color_changed)
box.pack_start(self.cp, True, True, 5)
self.add(box)
self.show_all()

#Set some initial parameters
self.w,self.h=10,10 #Size of zoomed image in pixels
self.count=0
self.window=self.get_window()
#set initial zoom image
self.zoomwin.set_from_pixbuf(self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES))
self.grabbing=False

def on_color_changed(self,widget=None, data=None):
#Print out x,y to widgets
display=Gdk.Display.get_default()
(screen,x,y,modifier)=display.get_pointer()
self.xcoor.set_text("x: %i" %x)
self.ycoor.set_text("y: %i" %y)


def get_image(self,w=None,h=None):
#Get a pixbuff image under pointer
if w==None: w=self.w
if h==None: h=self.h
display=Gdk.Display.get_default()
(screen,self.x,self.y,modifier)=display.get_pointer()
window=Gdk.get_default_root_window()
screenshot = Gdk.pixbuf_get_from_window(window,
self.x-int(w/2), self.y-int(h/2), int(w), int(h))
return screenshot

def motion_cb(self, widget, data):
#What to do while mouse pointer is moving
#DONT capture every event! Causes too much backup
if self.count==5:
self.pixbuf=self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES)
self.zoomwin.set_from_pixbuf(self.pixbuf)
self.zoomwin.queue_draw()
self.count=0
self.count+=1

def grab_start(self):
#Grab control of pointer outside of window
self.grabbing = True
Gdk.pointer_grab(self.window,
True, #allow passage of pointer events to children
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK,
None,
None,# could put a custom cursor here
0L)

def button_press(self,widget,data):
#capture color under the pointer and set the color selection
cenpx=self.get_image(1,1)
color=tuple(map(ord, cenpx.get_pixels()[:3]))
col=Gdk.RGBA(float(color[0])/256.,float(color[1])/256.,float(color[2])/256.)
self.cp.set_current_rgba(col)

def grab_stop(self):
#Stop Grabbing the pointer
Gdk.pointer_ungrab(0)
self.grabbing=False

def gobutton_activate(self, widget, data=None):
#Button control
if self.grabbing==False:
self.grab_start()
widget.set_label("Stop Picking")
else:
self.grab_stop()
widget.set_label("Pick Color")

def draw(self, widget, cr):
#this gets called, but nothing is drawn that I can see...
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_rgba(1,1,1,1)
w = self.w
h = self.h
cr.set_source_rgba(1,1,1,1)
cr.set_line_width(10)
cr.rectangle(w/2-1,h/2-1,w/2+1,h/2+1)
cr.stroke()
cr.set_operator(cairo.OPERATOR_OVER)


if __name__=="__main__":
win=picker()
Gtk.main()





share|improve this answer





















  • 1





    Nice answer. Much more straightforward.

    – snowguy
    Jul 24 '12 at 20:30






  • 1





    Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

    – Flash
    Jul 28 '12 at 3:32











  • Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

    – Ian B.
    Jul 28 '12 at 20:42



















4














If anybody wants to do this in the future, you do not need to download anything (certainly not hundreds of megabytes of Windows stuff as another answer suggests). A simple solution Ubuntu comes with is xmag. Xmag is part of the x11-apps package which should already be installed by default.



It's easy. Run xmag, click to pick a region of the screen, then hold down the mouse button in the magnified view to see the exact pixel coordinates.



Screenshot of xmag, sans pointer



You can read the xmag manual by typing man xmag.






share|improve this answer
























  • To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

    – dessert
    Sep 27 '17 at 6:32



















0














Try imview , it does show co-ordinates.



enter image description here



You can download its Doc page and man page here.






share|improve this answer
























  • I can't see how to select pixels from the screen with this.

    – Flash
    Jul 22 '12 at 12:40













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f163783%2ftool-to-easily-select-a-pixel-on-screen-and-get-color-and-absolute-coordinates%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























6 Answers
6






active

oldest

votes








6 Answers
6






active

oldest

votes









active

oldest

votes






active

oldest

votes









4





+50









The best fit is...a tiny Windows tool called ColorPix (via WINE)



After searching long and hard, it appears none of the available tools for Ubuntu/Linux fulfill both your criteria, i.e. magnification and coordinate display.



So we go for a tiny Windows tool that -- critically -- just works with a default WINE install, no configuration, installation, DLLs, etc. needed.





  • It features adjustable zoom, one-click copy in multiple formats and co-ordinate display:



    enter image description here




1. Install Wine



sudo apt-get install wine


(that's it!)



2. Download ColorPix



ColorPix can be officially downloaded as a tiny, portable 600KB exe here



I suggest downloading directly to your local binaries directory with:



sudo wget -O/usr/local/bin/ColorPix.exe http://www.colorschemer.com/ColorPix.exe


3. Create a launcher for ColorPix





  • Let's get an icon first:



    sudo wget -O/usr/share/icons/colorpix.png http://cdn.alternativeto.net/i/22e49edc-efa7-e011-979d-0025902c7e73_11865.png



  • Press Alt+F2 now and type gksudo gedit /usr/share/applications/colorpix.desktop, and paste the below and save the file:




    [Desktop Entry]
    Name=ColorPix
    GenericName=ColorPix
    Comment=ColorPicker via WINE
    Exec=wine /usr/local/bin/ColorPix.exe
    Terminal=false
    Icon=/usr/share/icons/colorpix.png
    Type=Application
    StartupNotify=true



  • From a terminal, run:



    sudo chmod +x /usr/share/applications/colorpix.desktop



  • In a few seconds, it will be available in the launcher as:



    enter image description here




4. Using ColorPix



Start it, and the very first time it may take a few seconds while WINE initializes.



The screenshot below shows it in action, with:




  • The coordinates on the top

  • Color values in different formats below (click to copy to clipboard)

  • Adjustable magnifier below


  • Press any key once you are on your desired pixel to lock values



    enter image description here








share|improve this answer
























  • Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

    – nealmcb
    Mar 2 '15 at 17:35













  • Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

    – hackerb9
    Nov 15 '18 at 16:05
















4





+50









The best fit is...a tiny Windows tool called ColorPix (via WINE)



After searching long and hard, it appears none of the available tools for Ubuntu/Linux fulfill both your criteria, i.e. magnification and coordinate display.



So we go for a tiny Windows tool that -- critically -- just works with a default WINE install, no configuration, installation, DLLs, etc. needed.





  • It features adjustable zoom, one-click copy in multiple formats and co-ordinate display:



    enter image description here




1. Install Wine



sudo apt-get install wine


(that's it!)



2. Download ColorPix



ColorPix can be officially downloaded as a tiny, portable 600KB exe here



I suggest downloading directly to your local binaries directory with:



sudo wget -O/usr/local/bin/ColorPix.exe http://www.colorschemer.com/ColorPix.exe


3. Create a launcher for ColorPix





  • Let's get an icon first:



    sudo wget -O/usr/share/icons/colorpix.png http://cdn.alternativeto.net/i/22e49edc-efa7-e011-979d-0025902c7e73_11865.png



  • Press Alt+F2 now and type gksudo gedit /usr/share/applications/colorpix.desktop, and paste the below and save the file:




    [Desktop Entry]
    Name=ColorPix
    GenericName=ColorPix
    Comment=ColorPicker via WINE
    Exec=wine /usr/local/bin/ColorPix.exe
    Terminal=false
    Icon=/usr/share/icons/colorpix.png
    Type=Application
    StartupNotify=true



  • From a terminal, run:



    sudo chmod +x /usr/share/applications/colorpix.desktop



  • In a few seconds, it will be available in the launcher as:



    enter image description here




4. Using ColorPix



Start it, and the very first time it may take a few seconds while WINE initializes.



The screenshot below shows it in action, with:




  • The coordinates on the top

  • Color values in different formats below (click to copy to clipboard)

  • Adjustable magnifier below


  • Press any key once you are on your desired pixel to lock values



    enter image description here








share|improve this answer
























  • Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

    – nealmcb
    Mar 2 '15 at 17:35













  • Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

    – hackerb9
    Nov 15 '18 at 16:05














4





+50







4





+50



4




+50





The best fit is...a tiny Windows tool called ColorPix (via WINE)



After searching long and hard, it appears none of the available tools for Ubuntu/Linux fulfill both your criteria, i.e. magnification and coordinate display.



So we go for a tiny Windows tool that -- critically -- just works with a default WINE install, no configuration, installation, DLLs, etc. needed.





  • It features adjustable zoom, one-click copy in multiple formats and co-ordinate display:



    enter image description here




1. Install Wine



sudo apt-get install wine


(that's it!)



2. Download ColorPix



ColorPix can be officially downloaded as a tiny, portable 600KB exe here



I suggest downloading directly to your local binaries directory with:



sudo wget -O/usr/local/bin/ColorPix.exe http://www.colorschemer.com/ColorPix.exe


3. Create a launcher for ColorPix





  • Let's get an icon first:



    sudo wget -O/usr/share/icons/colorpix.png http://cdn.alternativeto.net/i/22e49edc-efa7-e011-979d-0025902c7e73_11865.png



  • Press Alt+F2 now and type gksudo gedit /usr/share/applications/colorpix.desktop, and paste the below and save the file:




    [Desktop Entry]
    Name=ColorPix
    GenericName=ColorPix
    Comment=ColorPicker via WINE
    Exec=wine /usr/local/bin/ColorPix.exe
    Terminal=false
    Icon=/usr/share/icons/colorpix.png
    Type=Application
    StartupNotify=true



  • From a terminal, run:



    sudo chmod +x /usr/share/applications/colorpix.desktop



  • In a few seconds, it will be available in the launcher as:



    enter image description here




4. Using ColorPix



Start it, and the very first time it may take a few seconds while WINE initializes.



The screenshot below shows it in action, with:




  • The coordinates on the top

  • Color values in different formats below (click to copy to clipboard)

  • Adjustable magnifier below


  • Press any key once you are on your desired pixel to lock values



    enter image description here








share|improve this answer













The best fit is...a tiny Windows tool called ColorPix (via WINE)



After searching long and hard, it appears none of the available tools for Ubuntu/Linux fulfill both your criteria, i.e. magnification and coordinate display.



So we go for a tiny Windows tool that -- critically -- just works with a default WINE install, no configuration, installation, DLLs, etc. needed.





  • It features adjustable zoom, one-click copy in multiple formats and co-ordinate display:



    enter image description here




1. Install Wine



sudo apt-get install wine


(that's it!)



2. Download ColorPix



ColorPix can be officially downloaded as a tiny, portable 600KB exe here



I suggest downloading directly to your local binaries directory with:



sudo wget -O/usr/local/bin/ColorPix.exe http://www.colorschemer.com/ColorPix.exe


3. Create a launcher for ColorPix





  • Let's get an icon first:



    sudo wget -O/usr/share/icons/colorpix.png http://cdn.alternativeto.net/i/22e49edc-efa7-e011-979d-0025902c7e73_11865.png



  • Press Alt+F2 now and type gksudo gedit /usr/share/applications/colorpix.desktop, and paste the below and save the file:




    [Desktop Entry]
    Name=ColorPix
    GenericName=ColorPix
    Comment=ColorPicker via WINE
    Exec=wine /usr/local/bin/ColorPix.exe
    Terminal=false
    Icon=/usr/share/icons/colorpix.png
    Type=Application
    StartupNotify=true



  • From a terminal, run:



    sudo chmod +x /usr/share/applications/colorpix.desktop



  • In a few seconds, it will be available in the launcher as:



    enter image description here




4. Using ColorPix



Start it, and the very first time it may take a few seconds while WINE initializes.



The screenshot below shows it in action, with:




  • The coordinates on the top

  • Color values in different formats below (click to copy to clipboard)

  • Adjustable magnifier below


  • Press any key once you are on your desired pixel to lock values



    enter image description here









share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 28 '12 at 15:14









ishish

116k31268294




116k31268294













  • Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

    – nealmcb
    Mar 2 '15 at 17:35













  • Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

    – hackerb9
    Nov 15 '18 at 16:05



















  • Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

    – nealmcb
    Mar 2 '15 at 17:35













  • Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

    – hackerb9
    Nov 15 '18 at 16:05

















Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

– nealmcb
Mar 2 '15 at 17:35







Well-written, surprising answer - thanks! But it is hard to stomach 625 MB of download for wine, so I'm hoping Ian B gets some help with his cute little python app....

– nealmcb
Mar 2 '15 at 17:35















Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

– hackerb9
Nov 15 '18 at 16:05





Just use xmag, as described below, and hold down the mouse button on the pixel you want the coordinates of.

– hackerb9
Nov 15 '18 at 16:05













12














There is a tool called gpick.



Here you can see an image of the tool. With gpick you can select pixels, see the HTML code, add colors to the palette and generate colors.



To use it, right click the middle of the hexagon then use space bar to save colors into the palette.



gpick






share|improve this answer


























  • Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

    – Flash
    Jul 15 '12 at 12:14











  • Could you also mark this question as completed?

    – slashcrack
    Jul 15 '12 at 12:19











  • No - as I still don't have the answer :)

    – Flash
    Jul 22 '12 at 4:01











  • gpick looks great, just do sudo apt-get install gpick to install it

    – Bloke
    Oct 1 '15 at 15:54


















12














There is a tool called gpick.



Here you can see an image of the tool. With gpick you can select pixels, see the HTML code, add colors to the palette and generate colors.



To use it, right click the middle of the hexagon then use space bar to save colors into the palette.



gpick






share|improve this answer


























  • Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

    – Flash
    Jul 15 '12 at 12:14











  • Could you also mark this question as completed?

    – slashcrack
    Jul 15 '12 at 12:19











  • No - as I still don't have the answer :)

    – Flash
    Jul 22 '12 at 4:01











  • gpick looks great, just do sudo apt-get install gpick to install it

    – Bloke
    Oct 1 '15 at 15:54
















12












12








12







There is a tool called gpick.



Here you can see an image of the tool. With gpick you can select pixels, see the HTML code, add colors to the palette and generate colors.



To use it, right click the middle of the hexagon then use space bar to save colors into the palette.



gpick






share|improve this answer















There is a tool called gpick.



Here you can see an image of the tool. With gpick you can select pixels, see the HTML code, add colors to the palette and generate colors.



To use it, right click the middle of the hexagon then use space bar to save colors into the palette.



gpick







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 29 at 7:28









Jonathan

1,40531530




1,40531530










answered Jul 15 '12 at 10:04









slashcrackslashcrack

9302730




9302730













  • Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

    – Flash
    Jul 15 '12 at 12:14











  • Could you also mark this question as completed?

    – slashcrack
    Jul 15 '12 at 12:19











  • No - as I still don't have the answer :)

    – Flash
    Jul 22 '12 at 4:01











  • gpick looks great, just do sudo apt-get install gpick to install it

    – Bloke
    Oct 1 '15 at 15:54





















  • Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

    – Flash
    Jul 15 '12 at 12:14











  • Could you also mark this question as completed?

    – slashcrack
    Jul 15 '12 at 12:19











  • No - as I still don't have the answer :)

    – Flash
    Jul 22 '12 at 4:01











  • gpick looks great, just do sudo apt-get install gpick to install it

    – Bloke
    Oct 1 '15 at 15:54



















Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

– Flash
Jul 15 '12 at 12:14





Thanks this almost does what I want but doesn't seem to show the pixel coordinates.

– Flash
Jul 15 '12 at 12:14













Could you also mark this question as completed?

– slashcrack
Jul 15 '12 at 12:19





Could you also mark this question as completed?

– slashcrack
Jul 15 '12 at 12:19













No - as I still don't have the answer :)

– Flash
Jul 22 '12 at 4:01





No - as I still don't have the answer :)

– Flash
Jul 22 '12 at 4:01













gpick looks great, just do sudo apt-get install gpick to install it

– Bloke
Oct 1 '15 at 15:54







gpick looks great, just do sudo apt-get install gpick to install it

– Bloke
Oct 1 '15 at 15:54













6














This will get you what you want I believe. Admittedly it is a few steps but it looks worse than it is since I showed each little step.



Setup



Install ImageMagick & Shutter.



sudo apt-get install imagemagick shutter


How to get the x,y coordinates and color



A. Open Shutter and click the selection button



pic of clicking selection button



B. Note that as you move your mouse around it will show you the x,y coordinates you are looking for.



enter image description here



When you've got the right place go ahead and click with your mouse button and draw a square to capture an image. (It doesn't really matter how large your image is just so long as you start it (top left corner) on the pixel of interest.)



enter image description here



C. Close the image in shutter



enter image description here



D. Run the following command from the terminal. This will give you the color values of the top left pixel.



convert ~/Pictures/Selection_001.png -crop 1x1+1+1 txt:- | sed -n 's/.* (#.*)/1/p' 


E. While in the command line go ahead and delete the image so that the next time shutter takes a picture it gives it the same name. (Otherwise you'll need to adjust the name in the previous step (D).



rm ~/Pictures/Selection_001.png





share|improve this answer
























  • Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Jan 21 '17 at 12:20
















6














This will get you what you want I believe. Admittedly it is a few steps but it looks worse than it is since I showed each little step.



Setup



Install ImageMagick & Shutter.



sudo apt-get install imagemagick shutter


How to get the x,y coordinates and color



A. Open Shutter and click the selection button



pic of clicking selection button



B. Note that as you move your mouse around it will show you the x,y coordinates you are looking for.



enter image description here



When you've got the right place go ahead and click with your mouse button and draw a square to capture an image. (It doesn't really matter how large your image is just so long as you start it (top left corner) on the pixel of interest.)



enter image description here



C. Close the image in shutter



enter image description here



D. Run the following command from the terminal. This will give you the color values of the top left pixel.



convert ~/Pictures/Selection_001.png -crop 1x1+1+1 txt:- | sed -n 's/.* (#.*)/1/p' 


E. While in the command line go ahead and delete the image so that the next time shutter takes a picture it gives it the same name. (Otherwise you'll need to adjust the name in the previous step (D).



rm ~/Pictures/Selection_001.png





share|improve this answer
























  • Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Jan 21 '17 at 12:20














6












6








6







This will get you what you want I believe. Admittedly it is a few steps but it looks worse than it is since I showed each little step.



Setup



Install ImageMagick & Shutter.



sudo apt-get install imagemagick shutter


How to get the x,y coordinates and color



A. Open Shutter and click the selection button



pic of clicking selection button



B. Note that as you move your mouse around it will show you the x,y coordinates you are looking for.



enter image description here



When you've got the right place go ahead and click with your mouse button and draw a square to capture an image. (It doesn't really matter how large your image is just so long as you start it (top left corner) on the pixel of interest.)



enter image description here



C. Close the image in shutter



enter image description here



D. Run the following command from the terminal. This will give you the color values of the top left pixel.



convert ~/Pictures/Selection_001.png -crop 1x1+1+1 txt:- | sed -n 's/.* (#.*)/1/p' 


E. While in the command line go ahead and delete the image so that the next time shutter takes a picture it gives it the same name. (Otherwise you'll need to adjust the name in the previous step (D).



rm ~/Pictures/Selection_001.png





share|improve this answer













This will get you what you want I believe. Admittedly it is a few steps but it looks worse than it is since I showed each little step.



Setup



Install ImageMagick & Shutter.



sudo apt-get install imagemagick shutter


How to get the x,y coordinates and color



A. Open Shutter and click the selection button



pic of clicking selection button



B. Note that as you move your mouse around it will show you the x,y coordinates you are looking for.



enter image description here



When you've got the right place go ahead and click with your mouse button and draw a square to capture an image. (It doesn't really matter how large your image is just so long as you start it (top left corner) on the pixel of interest.)



enter image description here



C. Close the image in shutter



enter image description here



D. Run the following command from the terminal. This will give you the color values of the top left pixel.



convert ~/Pictures/Selection_001.png -crop 1x1+1+1 txt:- | sed -n 's/.* (#.*)/1/p' 


E. While in the command line go ahead and delete the image so that the next time shutter takes a picture it gives it the same name. (Otherwise you'll need to adjust the name in the previous step (D).



rm ~/Pictures/Selection_001.png






share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 23 '12 at 22:02









snowguysnowguy

3,11961924




3,11961924













  • Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Jan 21 '17 at 12:20



















  • Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    Jan 21 '17 at 12:20

















Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

– Ciro Santilli 新疆改造中心 六四事件 法轮功
Jan 21 '17 at 12:20





Convert is obviously the best option, but I'd rather go for rgba + od: askubuntu.com/a/874503/52975

– Ciro Santilli 新疆改造中心 六四事件 法轮功
Jan 21 '17 at 12:20











6














Paste this code into a text editor, make it executable and run it. When you choose a color with the eyedropper, the x and y coordinates will appear at the top.



Edit: Wrote code to add a zoom window. To have it grab pixels outside of the window click the button (not the eyedropper). Click the button again to stop grabbing the pointer. Haven’t figured out how to draw a crosshair with cairo, but you can probably use as is. I left some cairo code in there in case someone can tell me why my rectangle doesn’t draw…



#!/usr/bin/python
from gi.repository import Gtk,Gdk, GdkPixbuf
import cairo

class picker(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
self.connect('motion-notify-event', self.motion_cb)
self.connect('button-press-event',self.button_press)
box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

#Setup area for coordinates and zoom window
coordbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.xcoor=Gtk.Label("x: ")
coordbox.pack_start(self.xcoor, True, False, 1)
self.ycoor=Gtk.Label("y: ")
coordbox.pack_start(self.ycoor, True, False, 1)
self.zoomwin=Gtk.Image()
#Trying to draw on Gtk.Image with cairo for crosshairs... Not working
self.zoomwin.connect('draw', self.draw)
self.zoomwin.set_app_paintable(True)
coordbox.pack_start(self.zoomwin,True,True,1)
self.buttongo=Gtk.Button("Pick Color")
self.buttongo.connect('clicked',self.gobutton_activate)
coordbox.pack_start(self.buttongo,True,True,1)
box.pack_start(coordbox, True, False, 5)

#Put in color wheel for tweaking color
self.cp=Gtk.ColorSelection()
self.cp.connect('color-changed', self.on_color_changed)
box.pack_start(self.cp, True, True, 5)
self.add(box)
self.show_all()

#Set some initial parameters
self.w,self.h=10,10 #Size of zoomed image in pixels
self.count=0
self.window=self.get_window()
#set initial zoom image
self.zoomwin.set_from_pixbuf(self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES))
self.grabbing=False

def on_color_changed(self,widget=None, data=None):
#Print out x,y to widgets
display=Gdk.Display.get_default()
(screen,x,y,modifier)=display.get_pointer()
self.xcoor.set_text("x: %i" %x)
self.ycoor.set_text("y: %i" %y)


def get_image(self,w=None,h=None):
#Get a pixbuff image under pointer
if w==None: w=self.w
if h==None: h=self.h
display=Gdk.Display.get_default()
(screen,self.x,self.y,modifier)=display.get_pointer()
window=Gdk.get_default_root_window()
screenshot = Gdk.pixbuf_get_from_window(window,
self.x-int(w/2), self.y-int(h/2), int(w), int(h))
return screenshot

def motion_cb(self, widget, data):
#What to do while mouse pointer is moving
#DONT capture every event! Causes too much backup
if self.count==5:
self.pixbuf=self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES)
self.zoomwin.set_from_pixbuf(self.pixbuf)
self.zoomwin.queue_draw()
self.count=0
self.count+=1

def grab_start(self):
#Grab control of pointer outside of window
self.grabbing = True
Gdk.pointer_grab(self.window,
True, #allow passage of pointer events to children
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK,
None,
None,# could put a custom cursor here
0L)

def button_press(self,widget,data):
#capture color under the pointer and set the color selection
cenpx=self.get_image(1,1)
color=tuple(map(ord, cenpx.get_pixels()[:3]))
col=Gdk.RGBA(float(color[0])/256.,float(color[1])/256.,float(color[2])/256.)
self.cp.set_current_rgba(col)

def grab_stop(self):
#Stop Grabbing the pointer
Gdk.pointer_ungrab(0)
self.grabbing=False

def gobutton_activate(self, widget, data=None):
#Button control
if self.grabbing==False:
self.grab_start()
widget.set_label("Stop Picking")
else:
self.grab_stop()
widget.set_label("Pick Color")

def draw(self, widget, cr):
#this gets called, but nothing is drawn that I can see...
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_rgba(1,1,1,1)
w = self.w
h = self.h
cr.set_source_rgba(1,1,1,1)
cr.set_line_width(10)
cr.rectangle(w/2-1,h/2-1,w/2+1,h/2+1)
cr.stroke()
cr.set_operator(cairo.OPERATOR_OVER)


if __name__=="__main__":
win=picker()
Gtk.main()





share|improve this answer





















  • 1





    Nice answer. Much more straightforward.

    – snowguy
    Jul 24 '12 at 20:30






  • 1





    Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

    – Flash
    Jul 28 '12 at 3:32











  • Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

    – Ian B.
    Jul 28 '12 at 20:42
















6














Paste this code into a text editor, make it executable and run it. When you choose a color with the eyedropper, the x and y coordinates will appear at the top.



Edit: Wrote code to add a zoom window. To have it grab pixels outside of the window click the button (not the eyedropper). Click the button again to stop grabbing the pointer. Haven’t figured out how to draw a crosshair with cairo, but you can probably use as is. I left some cairo code in there in case someone can tell me why my rectangle doesn’t draw…



#!/usr/bin/python
from gi.repository import Gtk,Gdk, GdkPixbuf
import cairo

class picker(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
self.connect('motion-notify-event', self.motion_cb)
self.connect('button-press-event',self.button_press)
box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

#Setup area for coordinates and zoom window
coordbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.xcoor=Gtk.Label("x: ")
coordbox.pack_start(self.xcoor, True, False, 1)
self.ycoor=Gtk.Label("y: ")
coordbox.pack_start(self.ycoor, True, False, 1)
self.zoomwin=Gtk.Image()
#Trying to draw on Gtk.Image with cairo for crosshairs... Not working
self.zoomwin.connect('draw', self.draw)
self.zoomwin.set_app_paintable(True)
coordbox.pack_start(self.zoomwin,True,True,1)
self.buttongo=Gtk.Button("Pick Color")
self.buttongo.connect('clicked',self.gobutton_activate)
coordbox.pack_start(self.buttongo,True,True,1)
box.pack_start(coordbox, True, False, 5)

#Put in color wheel for tweaking color
self.cp=Gtk.ColorSelection()
self.cp.connect('color-changed', self.on_color_changed)
box.pack_start(self.cp, True, True, 5)
self.add(box)
self.show_all()

#Set some initial parameters
self.w,self.h=10,10 #Size of zoomed image in pixels
self.count=0
self.window=self.get_window()
#set initial zoom image
self.zoomwin.set_from_pixbuf(self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES))
self.grabbing=False

def on_color_changed(self,widget=None, data=None):
#Print out x,y to widgets
display=Gdk.Display.get_default()
(screen,x,y,modifier)=display.get_pointer()
self.xcoor.set_text("x: %i" %x)
self.ycoor.set_text("y: %i" %y)


def get_image(self,w=None,h=None):
#Get a pixbuff image under pointer
if w==None: w=self.w
if h==None: h=self.h
display=Gdk.Display.get_default()
(screen,self.x,self.y,modifier)=display.get_pointer()
window=Gdk.get_default_root_window()
screenshot = Gdk.pixbuf_get_from_window(window,
self.x-int(w/2), self.y-int(h/2), int(w), int(h))
return screenshot

def motion_cb(self, widget, data):
#What to do while mouse pointer is moving
#DONT capture every event! Causes too much backup
if self.count==5:
self.pixbuf=self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES)
self.zoomwin.set_from_pixbuf(self.pixbuf)
self.zoomwin.queue_draw()
self.count=0
self.count+=1

def grab_start(self):
#Grab control of pointer outside of window
self.grabbing = True
Gdk.pointer_grab(self.window,
True, #allow passage of pointer events to children
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK,
None,
None,# could put a custom cursor here
0L)

def button_press(self,widget,data):
#capture color under the pointer and set the color selection
cenpx=self.get_image(1,1)
color=tuple(map(ord, cenpx.get_pixels()[:3]))
col=Gdk.RGBA(float(color[0])/256.,float(color[1])/256.,float(color[2])/256.)
self.cp.set_current_rgba(col)

def grab_stop(self):
#Stop Grabbing the pointer
Gdk.pointer_ungrab(0)
self.grabbing=False

def gobutton_activate(self, widget, data=None):
#Button control
if self.grabbing==False:
self.grab_start()
widget.set_label("Stop Picking")
else:
self.grab_stop()
widget.set_label("Pick Color")

def draw(self, widget, cr):
#this gets called, but nothing is drawn that I can see...
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_rgba(1,1,1,1)
w = self.w
h = self.h
cr.set_source_rgba(1,1,1,1)
cr.set_line_width(10)
cr.rectangle(w/2-1,h/2-1,w/2+1,h/2+1)
cr.stroke()
cr.set_operator(cairo.OPERATOR_OVER)


if __name__=="__main__":
win=picker()
Gtk.main()





share|improve this answer





















  • 1





    Nice answer. Much more straightforward.

    – snowguy
    Jul 24 '12 at 20:30






  • 1





    Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

    – Flash
    Jul 28 '12 at 3:32











  • Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

    – Ian B.
    Jul 28 '12 at 20:42














6












6








6







Paste this code into a text editor, make it executable and run it. When you choose a color with the eyedropper, the x and y coordinates will appear at the top.



Edit: Wrote code to add a zoom window. To have it grab pixels outside of the window click the button (not the eyedropper). Click the button again to stop grabbing the pointer. Haven’t figured out how to draw a crosshair with cairo, but you can probably use as is. I left some cairo code in there in case someone can tell me why my rectangle doesn’t draw…



#!/usr/bin/python
from gi.repository import Gtk,Gdk, GdkPixbuf
import cairo

class picker(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
self.connect('motion-notify-event', self.motion_cb)
self.connect('button-press-event',self.button_press)
box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

#Setup area for coordinates and zoom window
coordbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.xcoor=Gtk.Label("x: ")
coordbox.pack_start(self.xcoor, True, False, 1)
self.ycoor=Gtk.Label("y: ")
coordbox.pack_start(self.ycoor, True, False, 1)
self.zoomwin=Gtk.Image()
#Trying to draw on Gtk.Image with cairo for crosshairs... Not working
self.zoomwin.connect('draw', self.draw)
self.zoomwin.set_app_paintable(True)
coordbox.pack_start(self.zoomwin,True,True,1)
self.buttongo=Gtk.Button("Pick Color")
self.buttongo.connect('clicked',self.gobutton_activate)
coordbox.pack_start(self.buttongo,True,True,1)
box.pack_start(coordbox, True, False, 5)

#Put in color wheel for tweaking color
self.cp=Gtk.ColorSelection()
self.cp.connect('color-changed', self.on_color_changed)
box.pack_start(self.cp, True, True, 5)
self.add(box)
self.show_all()

#Set some initial parameters
self.w,self.h=10,10 #Size of zoomed image in pixels
self.count=0
self.window=self.get_window()
#set initial zoom image
self.zoomwin.set_from_pixbuf(self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES))
self.grabbing=False

def on_color_changed(self,widget=None, data=None):
#Print out x,y to widgets
display=Gdk.Display.get_default()
(screen,x,y,modifier)=display.get_pointer()
self.xcoor.set_text("x: %i" %x)
self.ycoor.set_text("y: %i" %y)


def get_image(self,w=None,h=None):
#Get a pixbuff image under pointer
if w==None: w=self.w
if h==None: h=self.h
display=Gdk.Display.get_default()
(screen,self.x,self.y,modifier)=display.get_pointer()
window=Gdk.get_default_root_window()
screenshot = Gdk.pixbuf_get_from_window(window,
self.x-int(w/2), self.y-int(h/2), int(w), int(h))
return screenshot

def motion_cb(self, widget, data):
#What to do while mouse pointer is moving
#DONT capture every event! Causes too much backup
if self.count==5:
self.pixbuf=self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES)
self.zoomwin.set_from_pixbuf(self.pixbuf)
self.zoomwin.queue_draw()
self.count=0
self.count+=1

def grab_start(self):
#Grab control of pointer outside of window
self.grabbing = True
Gdk.pointer_grab(self.window,
True, #allow passage of pointer events to children
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK,
None,
None,# could put a custom cursor here
0L)

def button_press(self,widget,data):
#capture color under the pointer and set the color selection
cenpx=self.get_image(1,1)
color=tuple(map(ord, cenpx.get_pixels()[:3]))
col=Gdk.RGBA(float(color[0])/256.,float(color[1])/256.,float(color[2])/256.)
self.cp.set_current_rgba(col)

def grab_stop(self):
#Stop Grabbing the pointer
Gdk.pointer_ungrab(0)
self.grabbing=False

def gobutton_activate(self, widget, data=None):
#Button control
if self.grabbing==False:
self.grab_start()
widget.set_label("Stop Picking")
else:
self.grab_stop()
widget.set_label("Pick Color")

def draw(self, widget, cr):
#this gets called, but nothing is drawn that I can see...
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_rgba(1,1,1,1)
w = self.w
h = self.h
cr.set_source_rgba(1,1,1,1)
cr.set_line_width(10)
cr.rectangle(w/2-1,h/2-1,w/2+1,h/2+1)
cr.stroke()
cr.set_operator(cairo.OPERATOR_OVER)


if __name__=="__main__":
win=picker()
Gtk.main()





share|improve this answer















Paste this code into a text editor, make it executable and run it. When you choose a color with the eyedropper, the x and y coordinates will appear at the top.



Edit: Wrote code to add a zoom window. To have it grab pixels outside of the window click the button (not the eyedropper). Click the button again to stop grabbing the pointer. Haven’t figured out how to draw a crosshair with cairo, but you can probably use as is. I left some cairo code in there in case someone can tell me why my rectangle doesn’t draw…



#!/usr/bin/python
from gi.repository import Gtk,Gdk, GdkPixbuf
import cairo

class picker(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.connect('delete-event', Gtk.main_quit)
self.connect('motion-notify-event', self.motion_cb)
self.connect('button-press-event',self.button_press)
box=Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)

#Setup area for coordinates and zoom window
coordbox=Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.xcoor=Gtk.Label("x: ")
coordbox.pack_start(self.xcoor, True, False, 1)
self.ycoor=Gtk.Label("y: ")
coordbox.pack_start(self.ycoor, True, False, 1)
self.zoomwin=Gtk.Image()
#Trying to draw on Gtk.Image with cairo for crosshairs... Not working
self.zoomwin.connect('draw', self.draw)
self.zoomwin.set_app_paintable(True)
coordbox.pack_start(self.zoomwin,True,True,1)
self.buttongo=Gtk.Button("Pick Color")
self.buttongo.connect('clicked',self.gobutton_activate)
coordbox.pack_start(self.buttongo,True,True,1)
box.pack_start(coordbox, True, False, 5)

#Put in color wheel for tweaking color
self.cp=Gtk.ColorSelection()
self.cp.connect('color-changed', self.on_color_changed)
box.pack_start(self.cp, True, True, 5)
self.add(box)
self.show_all()

#Set some initial parameters
self.w,self.h=10,10 #Size of zoomed image in pixels
self.count=0
self.window=self.get_window()
#set initial zoom image
self.zoomwin.set_from_pixbuf(self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES))
self.grabbing=False

def on_color_changed(self,widget=None, data=None):
#Print out x,y to widgets
display=Gdk.Display.get_default()
(screen,x,y,modifier)=display.get_pointer()
self.xcoor.set_text("x: %i" %x)
self.ycoor.set_text("y: %i" %y)


def get_image(self,w=None,h=None):
#Get a pixbuff image under pointer
if w==None: w=self.w
if h==None: h=self.h
display=Gdk.Display.get_default()
(screen,self.x,self.y,modifier)=display.get_pointer()
window=Gdk.get_default_root_window()
screenshot = Gdk.pixbuf_get_from_window(window,
self.x-int(w/2), self.y-int(h/2), int(w), int(h))
return screenshot

def motion_cb(self, widget, data):
#What to do while mouse pointer is moving
#DONT capture every event! Causes too much backup
if self.count==5:
self.pixbuf=self.get_image().scale_simple(240,240,GdkPixbuf.InterpType.TILES)
self.zoomwin.set_from_pixbuf(self.pixbuf)
self.zoomwin.queue_draw()
self.count=0
self.count+=1

def grab_start(self):
#Grab control of pointer outside of window
self.grabbing = True
Gdk.pointer_grab(self.window,
True, #allow passage of pointer events to children
Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK,
None,
None,# could put a custom cursor here
0L)

def button_press(self,widget,data):
#capture color under the pointer and set the color selection
cenpx=self.get_image(1,1)
color=tuple(map(ord, cenpx.get_pixels()[:3]))
col=Gdk.RGBA(float(color[0])/256.,float(color[1])/256.,float(color[2])/256.)
self.cp.set_current_rgba(col)

def grab_stop(self):
#Stop Grabbing the pointer
Gdk.pointer_ungrab(0)
self.grabbing=False

def gobutton_activate(self, widget, data=None):
#Button control
if self.grabbing==False:
self.grab_start()
widget.set_label("Stop Picking")
else:
self.grab_stop()
widget.set_label("Pick Color")

def draw(self, widget, cr):
#this gets called, but nothing is drawn that I can see...
cr.set_operator(cairo.OPERATOR_SOURCE)
cr.set_source_rgba(1,1,1,1)
w = self.w
h = self.h
cr.set_source_rgba(1,1,1,1)
cr.set_line_width(10)
cr.rectangle(w/2-1,h/2-1,w/2+1,h/2+1)
cr.stroke()
cr.set_operator(cairo.OPERATOR_OVER)


if __name__=="__main__":
win=picker()
Gtk.main()






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 29 '18 at 22:35









Rory O'Kane

17717




17717










answered Jul 24 '12 at 18:26









Ian B.Ian B.

3,1481425




3,1481425








  • 1





    Nice answer. Much more straightforward.

    – snowguy
    Jul 24 '12 at 20:30






  • 1





    Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

    – Flash
    Jul 28 '12 at 3:32











  • Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

    – Ian B.
    Jul 28 '12 at 20:42














  • 1





    Nice answer. Much more straightforward.

    – snowguy
    Jul 24 '12 at 20:30






  • 1





    Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

    – Flash
    Jul 28 '12 at 3:32











  • Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

    – Ian B.
    Jul 28 '12 at 20:42








1




1





Nice answer. Much more straightforward.

– snowguy
Jul 24 '12 at 20:30





Nice answer. Much more straightforward.

– snowguy
Jul 24 '12 at 20:30




1




1





Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

– Flash
Jul 28 '12 at 3:32





Got it working - but I can't see the pixel I'm about to select until after I click it. I was hoping to be able to magnify the area around the cursor so I can make sure I get exactly the right pixel.

– Flash
Jul 28 '12 at 3:32













Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

– Ian B.
Jul 28 '12 at 20:42





Try it now... Interesting project and I learned a lot. Hope someone might be able to help me figure out why I can't draw on the zoom window with cairo.

– Ian B.
Jul 28 '12 at 20:42











4














If anybody wants to do this in the future, you do not need to download anything (certainly not hundreds of megabytes of Windows stuff as another answer suggests). A simple solution Ubuntu comes with is xmag. Xmag is part of the x11-apps package which should already be installed by default.



It's easy. Run xmag, click to pick a region of the screen, then hold down the mouse button in the magnified view to see the exact pixel coordinates.



Screenshot of xmag, sans pointer



You can read the xmag manual by typing man xmag.






share|improve this answer
























  • To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

    – dessert
    Sep 27 '17 at 6:32
















4














If anybody wants to do this in the future, you do not need to download anything (certainly not hundreds of megabytes of Windows stuff as another answer suggests). A simple solution Ubuntu comes with is xmag. Xmag is part of the x11-apps package which should already be installed by default.



It's easy. Run xmag, click to pick a region of the screen, then hold down the mouse button in the magnified view to see the exact pixel coordinates.



Screenshot of xmag, sans pointer



You can read the xmag manual by typing man xmag.






share|improve this answer
























  • To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

    – dessert
    Sep 27 '17 at 6:32














4












4








4







If anybody wants to do this in the future, you do not need to download anything (certainly not hundreds of megabytes of Windows stuff as another answer suggests). A simple solution Ubuntu comes with is xmag. Xmag is part of the x11-apps package which should already be installed by default.



It's easy. Run xmag, click to pick a region of the screen, then hold down the mouse button in the magnified view to see the exact pixel coordinates.



Screenshot of xmag, sans pointer



You can read the xmag manual by typing man xmag.






share|improve this answer













If anybody wants to do this in the future, you do not need to download anything (certainly not hundreds of megabytes of Windows stuff as another answer suggests). A simple solution Ubuntu comes with is xmag. Xmag is part of the x11-apps package which should already be installed by default.



It's easy. Run xmag, click to pick a region of the screen, then hold down the mouse button in the magnified view to see the exact pixel coordinates.



Screenshot of xmag, sans pointer



You can read the xmag manual by typing man xmag.







share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 27 '17 at 3:35









hackerb9hackerb9

2,6651813




2,6651813













  • To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

    – dessert
    Sep 27 '17 at 6:32



















  • To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

    – dessert
    Sep 27 '17 at 6:32

















To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

– dessert
Sep 27 '17 at 6:32





To change the magnification use the -mag option (defaults to 5), e.g. xmag -mag 10 to blow it up ten times.

– dessert
Sep 27 '17 at 6:32











0














Try imview , it does show co-ordinates.



enter image description here



You can download its Doc page and man page here.






share|improve this answer
























  • I can't see how to select pixels from the screen with this.

    – Flash
    Jul 22 '12 at 12:40


















0














Try imview , it does show co-ordinates.



enter image description here



You can download its Doc page and man page here.






share|improve this answer
























  • I can't see how to select pixels from the screen with this.

    – Flash
    Jul 22 '12 at 12:40
















0












0








0







Try imview , it does show co-ordinates.



enter image description here



You can download its Doc page and man page here.






share|improve this answer













Try imview , it does show co-ordinates.



enter image description here



You can download its Doc page and man page here.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 22 '12 at 6:49









atenzatenz

10.3k43559




10.3k43559













  • I can't see how to select pixels from the screen with this.

    – Flash
    Jul 22 '12 at 12:40





















  • I can't see how to select pixels from the screen with this.

    – Flash
    Jul 22 '12 at 12:40



















I can't see how to select pixels from the screen with this.

– Flash
Jul 22 '12 at 12:40







I can't see how to select pixels from the screen with this.

– Flash
Jul 22 '12 at 12:40




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f163783%2ftool-to-easily-select-a-pixel-on-screen-and-get-color-and-absolute-coordinates%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Human spaceflight

Can not write log (Is /dev/pts mounted?) - openpty in Ubuntu-on-Windows?

張江高科駅