Nicolas Guillaume
Nicolas Guillaume

Reputation: 8434

How to open a picture pixels in a 2D matrix

What gem can I use to open a picture in a 2D matrix? I want to be able to read and modify each pixel individually.

I'm using Ruby 1.9.

Upvotes: 1

Views: 443

Answers (3)

christianblais
christianblais

Reputation: 2458

ChunkyPNG is also a pretty good library if you want to work with PNGs.

Upvotes: 0

dfens
dfens

Reputation: 5515

If you need it only for operations that will not be massive: https://github.com/wvanbergen/chunky_png

If you don't want to use imagemagick but need speed boost (ruby library with C inlines): https://github.com/wvanbergen/oily_png

Upvotes: 0

wersimmon
wersimmon

Reputation: 2869

RMagick. Specifically you want the Image#pixel_color method.

There is also an each_pixel method to iterate through for reading.

Upvotes: 1

Related Questions