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