Class: Harmony::Service::Utils::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/harmony/service/utils/image.rb

Instance Method Summary collapse

Instance Method Details

#resize(uri, max_width, format: 'jpeg') ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/harmony/service/utils/image.rb', line 4

def resize(uri, max_width, format: 'jpeg')
  output_filepath = "/tmp/output.#{DateTime.now.strftime('%Q')}.#{format}"
  image = MiniMagick::Image.open(uri)
  image.resize max_width
  image.format format
  image.write output_filepath
  File.new(output_filepath)
end