Sha256: dae15f63941197dd38d97f79c452f0c07925ceeba7ee0b12bee77c9402b5b818

Contents?: true

Size: 860 Bytes

Versions: 5

Compression:

Stored size: 860 Bytes

Contents

require 'RMagick'

module Glue

# Magick transformation.
#--
# TODO: pass generalized RMagick command.
#++

module Thumbnails

  # Default thumbnail width.
  
  setting :width, :default => 128, :doc => 'Default thumbnail width'

  # Default thumbnail height.
  
  setting :height, :default => 128, :doc => 'Default thumbnail height'

  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

end

end

# * George Moschovitis <gm@navel.gr>
# * Michael Fellinger <m.fellinger@gmail.com>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.27.0 lib/glue/magick.rb
nitro-0.28.0 lib/glue/magick.rb
nitro-0.29.0 lib/glue/magick.rb
nitro-0.30.0 lib/glue/magick.rb
nitro-0.31.0 lib/glue/magick.rb