Module: MiniMagickClip

Defined in:
lib/mini_magick_clip.rb,
lib/mini_magick_clip/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#mask(mask_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mini_magick_clip.rb', line 6

def mask mask_path
  manipulate! do |img|
    img.format 'png'

    mask = ::MiniMagick::Image.open mask_path
    mask.resize([img[:width], img[:height]].join("x"))

    masked = img.composite(mask, 'png') do |i|
      i.alpha "set"
      i.compose 'DstIn'
    end
  end
end