Class: C80Yax::Watermarker

Inherits:
Object
  • Object
show all
Defined in:
lib/c80_yax/watermarker.rb

Instance Method Summary collapse

Constructor Details

#initialize(original_path, watermark_path) ⇒ Watermarker

Returns a new instance of Watermarker.



4
5
6
7
# File 'lib/c80_yax/watermarker.rb', line 4

def initialize(original_path, watermark_path)
  @original_path = original_path.to_s
  @watermark_path = watermark_path.to_s
end

Instance Method Details

#watermark!(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/c80_yax/watermarker.rb', line 9

def watermark!(options={})
  options[:gravity] ||= 'center'

  image = MiniMagick::Image.open(@original_path)
  watermark_image = MiniMagick::Image.open(@watermark_path)

  result = image.composite(watermark_image) do |c|
    c.gravity options[:gravity]
  end

  result.write @original_path

end