<p>I need to be able to quickly convert an image (inside a rails controller) so that the hosting company using managing our application can quickly test at any time to ensure that rmagick is not only successfully installed, but can be called throgh the rails stiack, what is the quickest clean code I can use to do this?</p>

[{'answer_id': 70932, 'author': 'tomafro', 'author_id': 7126, 'author_profile': 'https://Stackoverflow.com/users/7126', 'pm_score': 0, 'selected': False, 'text': "<p>I'd log on to the server and try out your code in script/console.  This will still go through the rails stack, but will allow you to quickly check that your code works the way you expect and that RMagick and ImageMagick are correctly installed without having to deploy anything.</p>\n\n<p>When the time comes to write your actual code, I'd suggest putting the image conversion code inside a model, so you can call it outside the context of a controller.</p>\n"}, {'answer_id': 70952, 'author': 'Asaf Bartov', 'author_id': 7483, 'author_profile': 'https://Stackoverflow.com/users/7483', 'pm_score': 0, 'selected': False, 'text': "<p>Use script/console, and call code in a model or a controller that does something like the following:</p>\n\n<pre><code>require 'RMagick'\ninclude Magick\nimg = ImageList.new('myfile.jpg')\nimg.crop(0,0,10,10) # or whatever\nimg.write('mycroppedfile.jpg')\n</code></pre>\n"}, {'answer_id': 71527, 'author': 'Laurie Young', 'author_id': 7473, 'author_profile': 'https://Stackoverflow.com/users/7473', 'pm_score': 3, 'selected': True, 'text': '<p>I wanted to do this so that I can easily hit it with a web browser, as I\'m deployng to managed servers, which I do not have shell access onto (for increased security).</p>\n\n<p>So this is what I did</p>\n\n<pre><code>class DiagnosticsController &lt; ApplicationController\n  require \'RMagick\'\n\n  def rmagick\n    images_path = "public/images"\n    file_name = "rmagick_generated_thumb.jpg"\n    file_path = images_path + "/"+ file_name\n\n    File.delete file_path if File.exists? file_path\n    img = Magick::Image.read("lib/sample_images/magic.jpg").first\n    thumb = img.scale(0.25)\n    @path = file_name\n    thumb.write file_path\n  end\nend #------\n</code></pre>\n\n<p>and then in rmagick.html.erb</p>\n\n<pre><code>&lt;%= image_tag @path %&gt;\n</code></pre>\n\n<p>Now I can hit the controller, and if I see an image, I know rmagic is installed.</p>\n'}, {'answer_id': 72582, 'author': 'Scott', 'author_id': 7399, 'author_profile': 'https://Stackoverflow.com/users/7399', 'pm_score': 4, 'selected': False, 'text': "<pre><code>require 'RMagick'\n\nimage = Magick::Image.new(110, 30){ self.background_color = 'white' }\nimage.write('/tmp/test.jpg')\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/70779', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7473/']