开发者

Image processing with barehands-ruby

I want to know how to open and manipulate a simple image file in Ruby language.

I don't need to do any advanced stuff, just things like open(), get_pixel() and put_pixel() and I don't wanna use any gem for doing that, but jus开发者_开发百科t to know the barehands-ruby way.


If by "simple image file" you refer to JPEG, GIF or so, it's tough luck because you'd have to implement all the decoding logic, which is far from being simple (take a look here for more info, but briefly because you really don't want to go into details ;)).

After decoding, eventually what you get is a matrix (two-dimensional array) of pixel information (usually three numbers for red, green and blue component, but other options exist). Then your methods get_pixel and set_pixel are trivial.

What Ruby folks usually do in such cases is wrap already existing C library for image manipulation, into a library such as rmagick.


Paperclip + ImageMagick did the trick. It's awesome and easy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜