Module: Raw::Mixin::Thumbnails

Defined in:
lib/raw/mixin/magick.rb

Overview

Magick transformation. – TODO: pass generalized RMagick command. ++

Class Method Summary collapse

Class Method Details

.generate_thumbnail(src, tname, geostring) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/raw/mixin/magick.rb', line 20

def self.generate_thumbnail(src, tname, geostring)
  ext = File.extname(src)
  dst = "#{File.join(File.dirname(src), File.basename(src, ext))}_#{tname}#{ext}"

  thumb = Magick::Image.read(File.join(Nitro::Server.public_root, src)).first
  thumb.change_geometry!(geostring) do |cols, rows, thumb|
    thumb.resize!(cols, rows)
  end
  thumb.write(File.join(Nitro::Server.public_root, dst))
  
  return dst
end