Module: Imogen::Scaled

Defined in:
lib/imogen.rb

Class Method Summary collapse

Class Method Details

.convert(img, dest_path, scale = 1500, format = :jpeg) ⇒ Object



19
20
21
22
23
24
# File 'lib/imogen.rb', line 19

def self.convert(img, dest_path, scale=1500, format = :jpeg)
  w = img.width
  h = img.height
  dims = (w > h) ? [scale, scale*h/w] : [scale*w/h, scale]
  img.thumbnail_image(dims[0], height: dims[1]).write_to_file(dest_path, background: [255, 255, 255])
end