I wanted to do this so that I could easily hit it with a web browser, as I deploy on managed servers on which I do not have access to the shell (to increase security).
So this is what I did
class DiagnosticsController < ApplicationController
require 'RMagick'
def rmagick
images_path = "public/images"
file_name = "rmagick_generated_thumb.jpg"
file_path = images_path + "/"+ file_name
File.delete file_path if File.exists? file_path
img = Magick::Image.read("lib/sample_images/magic.jpg").first
thumb = img.scale(0.25)
@path = file_name
thumb.write file_path
end
end
and then in rmagick.html.erb
<%= image_tag @path %>
, , , rmagic.