How to quickly do something in Rmagick to test it work

I need to be able to quickly convert the image (inside the rail controller) so that the hosting company using the management of our application can quickly test at any time to ensure that rmagick is not only successfully installed, but rails stiack can also be called, which is the fastest cleaning code that i can use for this?

+3
source share
4 answers

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.

+4
require 'RMagick'

image = Magick::Image.new(110, 30){ self.background_color = 'white' }
image.write('/tmp/test.jpg')
+14

script/. rails, , , , RMagick ImageMagick , -.

, , .

0

script/console , :

require 'RMagick'
include Magick
img = ImageList.new('myfile.jpg')
img.crop(0,0,10,10) # or whatever
img.write('mycroppedfile.jpg')
0

Source: https://habr.com/ru/post/1696942/


All Articles