我想允許在我的應用上裁剪。然而,當我運行這個方法:ImageMagick和回形針沒有找到我的文件在S3(Jcrop)上的位置
def avatar_geometry(style = :original)
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file avatar.path(style)
end
identify: unable to open image `/original/4/nutra.jpg': No such file or directory @ error/blob.c/OpenBlob/2587.
Paperclip::NotIdentifiedByImageMagickError: /original/4/nutra.jpg is not recognized by the 'identify' command.
from /Users/skline/.rvm/gems/[email protected]/gems/paperclip-cloudfiles-2.3.10.1/lib/paperclip/geometry.rb:26:in `from_file'
from /Users/skline/NutraNation1/app/models/user.rb:111:in `avatar_geometry'
from (irb):2
from /Users/skline/.rvm/gems/[email protected]/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /Users/skline/.rvm/gems/[email protected]/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /Users/skline/.rvm/gems/[email protected]/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
在回形針段出錯的代碼如下所示:
def self.from_file file
file = file.path if file.respond_to? "path"
geometry = begin
Paperclip.run("identify", "-format %wx%h :file", :file => "#{file}[0]")
rescue Cocaine::ExitStatusError
""
rescue Cocaine::CommandNotFoundError => e
raise Paperclip::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
end
parse(geometry) ||
raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command."))
end
我的化身模型是這樣的:
AVATAR_SW = 55
AVATAR_SH = 55
AVATAR_NW = 240
AVATAR_NH = 240
has_attached_file :avatar,
:styles => { :normal => ["#{AVATAR_NW}x#{AVATAR_NH}>", :jpg],
:small => ["#{AVATAR_SW}x#{AVATAR_SH}#", :jpg] }, :storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => "/:style/:id/:filename"
而且我給Paperclip在我的development.rb中找到ImageMagick的路線是這樣的:Paperclip.options[:command_path] = "/usr/local/bin/"
我已經證實這確實是ImageMagick的家園。
有趣的是,我可以上傳圖像沒有任何問題。簡單地說,當我試圖運行這個方法來裁剪它們時,我遇到了問題。有什麼建議麼。使用回形針(2.3.11)
請,請參閱本http://stackoverflow.com/a/12771707/1472432問題可能是在使用可卡因0.4。嘗試降級到可卡因0.3.2。回形針使用可卡因,但新的寶石版本使用錯誤的識別命令格式。 – 2012-10-08 16:51:01