RMagick is a complete interface between the Ruby programming language and the ImageMagick and GraphicsMagick image processing libraries. For details on how to install and use and for more info about RMagik see the user's guide.
Working with RMagick is very easy. Here are some examples:
The simplest example: read an image and display it
- Require the RMagick.rb
- Include the Magick module
- Create a new ImageList containing only one image
- Display the the list of images
You can convert an image from one format to another easily with RMagick:
I must stop here because there are many functions that you can apply to an image and I can't enumerate them All.
Conclusion:
With RMagick you have an easy to use and powerful tool to manipulate images. Try it your self.
Working with RMagick is very easy. Here are some examples:
The simplest example: read an image and display it
require 'RMagick'In this example, the following actions are done:
include Magick
im = ImageList.new("image1.jpg")
im.display
exit
- Require the RMagick.rb
- Include the Magick module
- Create a new ImageList containing only one image
- Display the the list of images
You can convert an image from one format to another easily with RMagick:
im = ImageList.new("image1.jpg")
im.write("image1.gif")As simple as that. You can create annimated gif from a number of gif images:im = ImageList.new("image1.gif", "image2.gif", "image3.gif")
im.write("annim.gif")You can create image and add text:# We create the backgroundYou can make thumbnails:
logo = Magick::ImageList.new('logo:')
img = Magick::ImageList.new
img.new_image(200, 100, Magick::TextureFill.new(logo))
# We set some text properties
text = Magick::Draw.new
text.font_family = 'helvetica'
text.pointsize = 52
# We write the text and set its color
text.annotate(img, 0,0,2,2, "Must@p") {
self.fill = 'darkred'
}
# We reduce the image to 20% of its sizeYou can rotate an image:
im1 = Image.new "image1.gif"
im2 = im1.scale(0.20)
im2.write "small.gif"
im1 = Image.new "image1.gif"You can add a shadow to an image:
im2 = Im1.rotate(30); # 30 degrees
im1 = Image.new "image1.gif"There are many effects that you can add to an image. See the manual.
# x_offset=5, y_offset=5, sigma=4.0, opacity=1.0
im2 = Im1.shadow(5,5,4.0,1.0);
I must stop here because there are many functions that you can apply to an image and I can't enumerate them All.
Conclusion:
With RMagick you have an easy to use and powerful tool to manipulate images. Try it your self.
18 Apr 2006 05:07:54
I'm curious how you created the image below, for anti-bot protection.
28 Jun 2006 14:11:40
it works nice !!
just try it ...