Posts Tagged ‘rmagick’

I spent a good amount of time in digging about another ruby gem.
RMagick is the magic gem I am talking about.In ruby, magic means
something amazing, something wow.You don’t have to scratch your
head to know about much of the background details. Just know how
to use it, and it’s all done!

RMagick is a binding from Ruby to the ImageMagick library. You can
use it to resize images, create thumbnails of images in a directory,
crop images, create watermarks for images and much more.

+ “rmagick” is the gems you need to include.

+ Magick::Image.read is a method returns an array if you will try to open gif
animation with multiple frames. In our case, we will get a single frame as it’s
a png image. And “.first” gives us the 1st frame which is the image itself.

+ change_gemometry method takes a new size as an argument and passes
the value to the associated blocks.

+ resize! method resizes the image and write saves the files with a new name.

You may like to try out other features of RMagick. Like conversation of image
formats. (PNG to JPG or others!)