Sha256: 28ece07167329155fbbd0756e8dce9595773f6f85596fdd83e400eabc9552823

Contents?: true

Size: 345 Bytes

Versions: 2

Compression:

Stored size: 345 Bytes

Contents

require 'mini_magick'

class Harmony::Service::Utils::Image
  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
harmony-service-0.8.3 lib/harmony/service/utils/image.rb
harmony-service-0.8.2 lib/harmony/service/utils/image.rb