質問

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