Class: ElFinderS3::Image
- Inherits:
-
Object
- Object
- ElFinderS3::Image
- Defined in:
- lib/el_finder_s3/image.rb
Overview
Represents default image handler. It uses mogrify to resize images and convert to create thumbnails.
Class Method Summary collapse
- .resize(pathname, options = {}) ⇒ Object
- .size(pathname) ⇒ Object
-
.thumbnail(imgSourcePath, dst, options = {}) ⇒ Object
of self.resize.
Class Method Details
.resize(pathname, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/el_finder_s3/image.rb', line 19 def self.resize(pathname, = {}) return nil unless File.exist?(pathname) system(::Shellwords.join(['mogrify', '-resize', "#{[:width]}x#{[:height]}!", pathname.to_s])) end |
.size(pathname) ⇒ Object
12 13 14 15 16 17 |
# 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 = {}) ⇒ Object
of self.resize
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/el_finder_s3/image.rb', line 26 def self.thumbnail(imgSourcePath, dst, = {}) image = MiniMagick::Image.open(imgSourcePath) image. do |c| c.thumbnail "#{[:width]}x#{[:height]}" c.background 'white' c.gravity 'center' c.extent "#{[:width]}x#{[:height]}" end dst.write(image) end |