Dragonfly Gem with ImageMagick and Passenger

雨燕双飞 提交于 2019-12-11 00:19:08

问题


I was having some problems getting the dragonfly gem to play nicely with passenger. Passenger doesn't seem to use the current $PATH so it can't find the convert binary. I've added some configuration to dragonfly which seems to solve the issue:

require 'dragonfly/rails/images'

Dragonfly[:images].configure do |c|
  c.convert_command  = "/usr/local/bin/convert" # defaults to "convert"
  c.identify_command = "/usr/local/bin/convert" # defaults to "convert"
end

but the gem i'm working on is going to be used as an engine and it's going to be a real pain to have to manually set the location to the imagemagick utilities for each install if passenger is used, is there a better solution to automatically specify the location to convert if available?


回答1:


Hey mario, try something like this. I've been using it to resolve pathing problems with passenger+paperclip+rmagick.

path = `which convert`.strip.gsub('convert','').presence || "/usr/local/bin/"

It should return /usr/local/bin when convert isn't in the path or unable to be found.



来源:https://stackoverflow.com/questions/6008183/dragonfly-gem-with-imagemagick-and-passenger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!