Module: Zbox::Qm

Defined in:
lib/zbox/img/qm.rb

Class Method Summary collapse

Class Method Details

.resize(filepath, opts = {}) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zbox/img/qm.rb', line 4

def self.resize(filepath,opts={})
  img = QuickMagick::Image.open(filepath).first
  if opts[:width] 
    mw = opts[:width]
  elsif opts[:height]
    mh = opts[:height]
  end
  mw ||= img.width
  mh ||= img.height
  if opts[:percent]
    img.resize opts[:percent]
  else
    img.resize "#{mw}x#{mh}"
  end 
  img.save! 
end