我想允许在我的应用上裁剪。然而,当我运行这个方法: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