Getting the color of a pixel


#1

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


#2

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

  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

Cheers,
Antonio