Image grab in Python

2008-05-04 Thread Valerio Valerio
Hi,

anyone know a Python library to grab the size of a selected image region
(the selection will be made with the mouse), that work in Linux ?

I found a module to do that in the PIL library but only work in Windows -
http://www.pythonware.com/library/pil/handbook/imagegrab.htm

Thanks in advance.

Best regards,

-- 
Valério Valério

http://www.valeriovalerio.org
--
http://mail.python.org/mailman/listinfo/python-list

Re: Image grab in Python

2008-05-04 Thread Valerio Valerio
I can grab the image,  I need a way of grab the region size with the mouse,
a easy way of the user select a region of the image to analyze, something
like the  "Rectangle selection tool" of gimp.

Regards,

-- 
Valério Valério

http://www.valeriovalerio.org

2008/5/4 David <[EMAIL PROTECTED]>:

> On Sun, May 4, 2008 at 4:25 PM, Valerio Valerio <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > anyone know a Python library to grab the size of a selected image region
> > (the selection will be made with the mouse), that work in Linux ?
>
> You might be able to use this tool:
>
> http://freshmeat.net/projects/gtkshots/
>
> David.
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: Image grab in Python

2008-05-04 Thread Valerio Valerio
Hi,

2008/5/4 David <[EMAIL PROTECTED]>:

> On Sun, May 4, 2008 at 5:28 PM, Valerio Valerio <[EMAIL PROTECTED]> wrote:
> > I can grab the image,  I need a way of grab the region size with the
> mouse,
> > a easy way of the user select a region of the image to analyze,
> something
> > like the  "Rectangle selection tool" of gimp.
> >
>
> I assume what you want to do is allow the user to drag the mouse
> across your desktop, and your program, running in the background,
> picks this up? As opposed to the user making a rectangular selection
> entirely within your app.


What I want is display a window with a image, the user select a region of
the image, and the region value is passed to my program, my program slice
the image region, and analyze it.

I think the Xlib libraries can help in my task, thanks for the help :)

Cheers,

-- 
Valério Valério

http://www.valeriovalerio.org


>
> I think the simplest way to do this is to capture the entire screen,
> then show it as an image on a window covering the entire screen (eg:
> fullscreen mode, or a regular window without decorations).  Then
> listen for mouse events. There should be a way to show the 'rectangle
> elastic band' at the same time. Otherwise just draw a rectangle
> between where the user first clicked and where the mouse is now (until
> they release the mouse button).
>
> Another way would be to listen to all events sent through X, and act
> based on the mouse events. VNC does something similar.
>
> A good starting point would be the Python xlib libraries:
>
> http://python-xlib.sourceforge.net/
>
> David.
>
--
http://mail.python.org/mailman/listinfo/python-list

Re: Image grab in Python

2008-05-04 Thread Valerio Valerio
2008/5/4 David <[EMAIL PROTECTED]>:

> > What I want is display a window with a image, the user select a region
> of
> > the image, and the region value is passed to my program, my program
> slice
> > the image region, and analyze it.
> >
>
> If it's your apps own window, then getting a rectangle selected by the
> user is simple.
>
> 1) Make skeleton x/gtk/wx/qt/etc app
> 2) Add code to show an image
> 3) Add code to capture mouse events
> 4) Add code to show the 'rubber band' rectangle over the mouse selection
> area
> 5) When the user releases the mouse, then extract the part of the
> rectangle between where a mouse button was clicked and where it was
> released.
>
> All this would be in the docs for the Python x/gtk/wx/qt/etc libs.
> Where is the difficulty?


Right now I don't have any difficulty :)
I just asked for a library to do that, if exist I don't have to write all
the things from scratch (the selection part), but I am able to do my tasks
easily with Xlib or Pygame.

Thanks for the help.

Cheers,

-- 
Valério Valério

http://www.valeriovalerio.org


>
> David.
>
--
http://mail.python.org/mailman/listinfo/python-list