0

我在我的 Rails 项目中使用 IMGkit gem。我还安装wkhtmltoimage-binary了 IMGkit 工作所必需的。IMGkit 和 wkhtmltoimage-binary 都是通过 gemfile 安装的。根据config/initializers/imgkit.rb我有

IMGKit.configure do |config|
  config.wkhtmltoimage = '/Users/Praveen/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/wkhtmltoimage-binary-0.12.2'
  config.default_format = :png
end

apps_controller.rb

def index

kit = IMGKit.new(html, :quality => 50)

# Get the image BLOB
img = kit.to_img

# Save to a file
file = kit.to_file('/path/to/save/file2.jpg')

# send to browser (Rails - use with #caches_page)
send_data(kit.to_img, :type => "image/jpeg", :disposition => 'inline')

结尾

运行时出现以下错误

在此处输入图像描述

虽然文件夹权限是 777。对此有任何帮助。提前致谢。

4

1 回答 1

0

我自己想通了。

imgkit.rb如果您wkhtmltoimage-binary通过 gemfile安装,则无需提供以下信息。

config.wkhtmltoimage = '/Users/Praveen/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/wkhtmltoimage-binary-0.12.2'
于 2015-10-17T13:22:40.450 回答