Вопрос

Here is action to generate png that works in development environment.

  def action
    html = "<b>test</b>"
    snap = IMGKit.new(html, :'crop-h' => 750, :'crop-h' => 290, quality: 50)

    respond_to do |format|
      format.png { send_data snap.to_img(:png) }
    end
  end

But on CentOS (production) server it generates only blank file. Note that this code WORKS from rails console on production server, but it does not work inside the controller action.

  html = "<b>test</b>"
  snap = IMGKit.new(html, :'crop-h' => 750, :'crop-h' => 290, quality: 50)

Is it a threading issue?

Это было полезно?

Решение

Somehow it worked:

 -    respond_to do |format|
 -      format.png { send_data snap.to_img(:png) }
 -    end
 +    send_data snap.to_img(:jpg)

Note that in my case there was no difference which format to use, lossy .jpg or lossless .png

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top