Tuesday, February 7, 2012

specular reflection with mini_magick (1)

"Specular Reflection" - a.k.a. "mirror effect" - is the most popular effect for image file to be good-looking. This effect consists of 4 operations.
  1. clone from original image and rotate it
  2. add transparency to cloned image
  3. combine original image and cloned one
  4. resize combined image
In this article, I introduce the operation of both (1) and (2) with referring ImageMagick's sample page and using mini_magick.

This ruby script is like below:
require 'mini_magick'

image_original = MiniMagick::Image.open("original.jpg")

image_cloned = image_original.clone

image_cloned.combine_options do |c|
  c.flip
  c.fill 'white' # set background color
  c.colorize '65%'
end

image_cloned.write "cloned_rotate_transparent.jpg"

You can change the argument(color name) of fill method depending on the background color where you want to put the image file onto. These are original image and rotated and transparent one.


(continue to phosphorescence: specular reflection with mini_magick (2))

No comments:

Post a Comment