# Getting the color of a pixel

**URL:** <https://www.ruby-forum.com/t/getting-the-color-of-a-pixel/76574>\
**Category:** Ruby\
**Created:** [December 26, 2005, 10:13pm UTC](https://www.ruby-forum.com/t/getting-the-color-of-a-pixel/76574 "2005-12-26T22:13:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [December 26, 2005, 10:13pm UTC](https://www.ruby-forum.com/t/getting-the-color-of-a-pixel/76574/1 "2005-12-26T22:13:53Z")

</div>

Hi,

I have a few questions about RMagick:

1. How do I get the color of a specific pixel? (By giving it the  
coordinates of the pixel)
2. How do I store parts of a picture to a file? (So like everything  
between points (3,7) and (90,300))

Thanks,

Thomas

---

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [December 26, 2005, 10:35pm UTC](https://www.ruby-forum.com/t/getting-the-color-of-a-pixel/76574/2 "2005-12-26T22:35:41Z")

</div>

Thomas wrote:

> Hi,

Hi Thomas,

> 1. How do I get the color of a specific pixel? (By giving it the  
> coordinates of the pixel)

Image.pixel\_color:  
[http://www.simplesystems.org/RMagick/doc/image2.html#pixel\_color](http://www.simplesystems.org/RMagick/doc/image2.html#pixel_color)

> 1. How do I store parts of a picture to a file? (So like everything  
> between points (3,7) and (90,300))

You could use:  
Image.crop(x, y, width, height)

Where x and y are the offsets of the rectangle relative to the  
upper-left corner of the image. width and height are the dimensions of  
your desidered region.  
[http://www.simplesystems.org/RMagick/doc/image1.html#crop](http://www.simplesystems.org/RMagick/doc/image1.html#crop)

Cheers,  
Antonio
