# X screen capture

**URL:** <https://www.ruby-forum.com/t/x-screen-capture/64310>\
**Category:** Ruby\
**Created:** [June 24, 2006, 2:08am UTC](https://www.ruby-forum.com/t/x-screen-capture/64310 "2006-06-24T02:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 24, 2006, 2:08am UTC](https://www.ruby-forum.com/t/x-screen-capture/64310/1 "2006-06-24T02:08:06Z")

</div>

Hi,  
I started rewriting a screen capture application of mine in ruby in  
order  
to test some ruby bindings for the Enlightenment Foundation Libraries).  
In the c version, I use Imlib2 to grab screen data, but it doesn’t look  
like the imlib2 ruby bindings can do this yet. (The X specific calls  
aren’t finished).

I next thought about using RMagick, but it seems as though it can only  
capture the entire screen. Is this a limitation of RMagick or  
ImageMagick?

Finally, are there any other ruby-bound libs out there that can grab  
pixel data from the screen?

Thanks,  
Brian Mattern

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 24, 2006, 2:26am UTC](https://www.ruby-forum.com/t/x-screen-capture/64310/2 "2006-06-24T02:26:33Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Finally, are there any other ruby-bound libs out there that can grab  
> pixel data from the screen?
> 
> Thanks,  
> Brian Mattern

You can use Magick::Image.capture to capture individual windows. Set  
self.filename to the window id:

img = Magick::Image.capture { self.filename = “0x60000e” }

[http://www.simplesystems.org/RMagick/doc/image1.html#capture](http://www.simplesystems.org/RMagick/doc/image1.html#capture)

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 24, 2006, 6:31am UTC](https://www.ruby-forum.com/t/x-screen-capture/64310/3 "2006-06-24T06:31:53Z")

</div>

On Sat, Jun 24, 2006 at 09:24:51AM +0900, Timothy H. wrote:

> > 
> 
> img = Magick::Image.capture { self.filename = “0x60000e” }
> 
> [RMagick 1.15.0: class Image (class and instance methods, part 1)](http://www.simplesystems.org/RMagick/doc/image1.html#capture)

Yeah, I realized that. Meant to say “entire window” in the original  
email 🙂

What I’d like to do is grab only a certain size region around the mouse  
cursor. (Zooming in on that area as you move the mouse around.) Maybe  
the screenshot at [http://rephorm.com/code/elicit](http://rephorm.com/code/elicit) will clarify a bit.

I may just need to pick up the imlib2 bindings where they were left off.
