Class: Sprite::ImageCombiner
- Inherits:
-
Object
- Object
- Sprite::ImageCombiner
- Defined in:
- lib/sprite/image_combiner.rb
Instance Method Summary collapse
- #composite_images(dest_image, src_image, x, y) ⇒ Object
-
#image_properties(image) ⇒ Object
Image Utility Methods.
-
#initialize(image_config) ⇒ ImageCombiner
constructor
A new instance of ImageCombiner.
Constructor Details
#initialize(image_config) ⇒ ImageCombiner
Returns a new instance of ImageCombiner.
3 4 5 6 7 |
# File 'lib/sprite/image_combiner.rb', line 3 def initialize(image_config) # avoid loading rmagick till the last possible moment require 'rmagick' @image_config = image_config end |
Instance Method Details
#composite_images(dest_image, src_image, x, y) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sprite/image_combiner.rb', line 9 def composite_images(dest_image, src_image, x, y) width = [src_image.columns + x, dest_image.columns].max height = [src_image.rows + y, dest_image.rows].max image = Magick::Image.new(width, height) if @image_config.background_color image.opacity = 0 else image.opacity = Magick::MaxRGB end image.composite!(dest_image, 0, 0, Magick::OverCompositeOp) image.composite!(src_image, x, y, Magick::OverCompositeOp) image end |
#image_properties(image) ⇒ Object
Image Utility Methods
26 27 28 |
# File 'lib/sprite/image_combiner.rb', line 26 def image_properties(image) {:name => File.basename(image.filename).split('.')[0], :width => image.columns, :height => image.rows} end |