蜻蜓宝石与ImageMagick和乘客 [英] Dragonfly Gem with ImageMagick and Passenger
问题描述
我在让蜻蜓宝石与乘客很好地玩耍时遇到了一些问题。 Passenger似乎没有使用当前的$ PATH,因此无法找到转换二进制文件。我已经为dragonfly添加了一些配置,这似乎解决了这个问题:
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
但我正在研究的宝石将被用作引擎而且它是如果使用乘客,必须为每次安装手动设置位置到imagemagick实用程序真的很痛苦,是否有更好的解决方案自动指定转换位置(如果可用)?
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?
推荐答案
嘿马里奥,尝试这样的事情。我一直用它来解决乘客+回形针+ rmagick的路径问题。
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/"
当转换为isn时,它应返回/ usr / local / bin在路上或无法找到。
It should return /usr/local/bin when convert isn't in the path or unable to be found.
这篇关于蜻蜓宝石与ImageMagick和乘客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!