require 'mini_magick' class Harmony::Service::Utils::Image def resize(uri, max_file_size) output_filepath = "/tmp/output.#{DateTime.now.strftime('%Q')}.png" image = MiniMagick::Image.open(uri) image.define "extent=#{max_file_size}" image.format 'jpeg' image.write output_filepath File.new(output_filepath) end end