Whenever we want to do something with ruby then at first we have work it out in irb console
Before proceeding for the crop we have to get the width,height and x,y co-ordinates of the image.

For cropping the image we have to use the instance method Crop
img.crop(x, y, width, height) -> image
img.crop(gravity, x, y, width, height) -> image
img.crop(gravity, width, height) -> image
#!/usr/bin/ruby -w
require 'rubygems'
require 'rmagick'
include Magick
image=Image.read("/home/Mac/Desktop/flowers.jpg").first
face=image.crop!(270,55,194,194)
face.write("/home/Mac/Desktop/crop.jpg")
Note*: This Program tested and works in all Linux system.
thanks! it looks amazing!
ReplyDelete