class Alchemy::Custom::Model::ElFinder::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/alchemy/custom/model/el_finder/image.rb, line 21
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/alchemy/custom/model/el_finder/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
rescue
  nil
end
thumbnail(src, dst, options = {}) click to toggle source

of self.resize

# File lib/alchemy/custom/model/el_finder/image.rb, line 28
def self.thumbnail(src, dst, options = {})
  return nil unless File.exist?(src)
  system(::Shellwords.join(['convert', '-resize', "#{options[:width]}x#{options[:height]}", '-background', 'white', '-gravity', 'center', '-extent', "#{options[:width]}x#{options[:height]}", src.to_s, dst.to_s]))
end