#! /usr/local/bin/ruby -w
require 'RMagick'

# Demonstrate the Image#blur_image method

lighthouse = Magick::Image.read('images/Lighthouse.jpg').first

# Crop to the interesting part of the picture.
lighthouse = lighthouse.crop(202, 184, 206, 230)

# Make a blurry copy.
blurry = lighthouse.blur_image(0.0,2.5)

# Copy the copy, retaining only the right half.
blurry = blurry.crop(blurry.columns/2, 0, blurry.columns/2, blurry.rows)

# Composite the copy over the right half of the original.
result = lighthouse.composite(blurry, Magick::EastGravity, Magick::OverCompositeOp)

# Draw a white line down the middle to emphasize the
# border between the original image and the blurry image.
line = Magick::Draw.new
line.stroke('white')
line.stroke_width(1)
line.line(lighthouse.columns/2, 0, lighthouse.columns/2, lighthouse.rows)
line.draw(result)

#result.display
result.write('blur_image.jpg')
exit
