class ElFinderS3::Image

Represents default image handler. It uses mogrify to resize images and convert to create thumbnails.

Public Class Methods

resize(pathname, options = {}) click to toggle source
# File lib/el_finder_s3/image.rb, line 19
def self.resize(pathname, options = {})
  return nil unless File.exist?(pathname)
  system(::Shellwords.join(['mogrify', '-resize', "#{options[:width]}x#{options[:height]}!", pathname.to_s]))
end
size(pathname) click to toggle source
# File lib/el_finder_s3/image.rb, line 12
def self.size(pathname)
  return nil unless File.exist?(pathname)
  s = ::ImageSize.new(File.open(pathname)).size.to_s
  s = nil if s.empty?
  return s
end
thumbnail(imgSourcePath, dst, options = {}) click to toggle source

of self.resize

# File lib/el_finder_s3/image.rb, line 26
def self.thumbnail(imgSourcePath, dst, options = {})
  image = MiniMagick::Image.open(imgSourcePath)
  image.combine_options do |c|
    c.thumbnail "#{options[:width]}x#{options[:height]}"
    c.background 'white'
    c.gravity 'center'
    c.extent "#{options[:width]}x#{options[:height]}"
  end
  dst.write(image)
end