Class: FlatironS3Uploader::ImageResizer
- Inherits:
-
Object
- Object
- FlatironS3Uploader::ImageResizer
- Defined in:
- lib/flatiron_s3_uploader/image_resizer.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ ImageResizer
constructor
A new instance of ImageResizer.
- #mime_type ⇒ Object
- #resize(width: nil, height: nil) ⇒ Object
Constructor Details
#initialize(path) ⇒ ImageResizer
Returns a new instance of ImageResizer.
9 10 11 12 13 14 |
# File 'lib/flatiron_s3_uploader/image_resizer.rb', line 9 def initialize(path) raise FlatironS3Uploader::FileNotFoundError unless File.exist?(path) @path = path @image = MiniMagick::Image.open(path) end |
Instance Attribute Details
#image ⇒ Object (readonly)
Returns the value of attribute image.
7 8 9 |
# File 'lib/flatiron_s3_uploader/image_resizer.rb', line 7 def image @image end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/flatiron_s3_uploader/image_resizer.rb', line 7 def path @path end |
Instance Method Details
#mime_type ⇒ Object
22 23 24 |
# File 'lib/flatiron_s3_uploader/image_resizer.rb', line 22 def mime_type image.mime_type end |
#resize(width: nil, height: nil) ⇒ Object
16 17 18 19 20 |
# File 'lib/flatiron_s3_uploader/image_resizer.rb', line 16 def resize(width: nil, height: nil) image.resize("#{width}x#{height}") image.write(output_path) output_path end |