调整大小错误 - 回形针::错误:: NotIdentifiedByImageMagickError

问题描述:

我刚刚安装回形针到我的应用程序上传图像,并且一切都很好,直到我试图添加样式来调整图像大小。 (我可以罚款上传图片之前,我添加此代码)调整大小错误 - 回形针::错误:: NotIdentifiedByImageMagickError

上pins.rb:

has_attached_file :image, styles: { medium: "300x300>" } 

我加入了类在_pin.html.rb:

<td><%= image_tag pin.image(:medium) %></td> 

但现在,当我尝试并上传图片,我得到的错误:

Paperclip::Errors::NotIdentifiedByImageMagickError 

当我删除的样式,它工作正常(alebit未调整),但一些在调整大小是搞砸了一切。我尝试了不同的文件类型和文件名。我在谷歌搜索了这个错误,所有的解决方案都不适合我。最流行的是降级可卡因,但是当我尝试它,我得到的消息:

Bundler could not find compatible versions for gem "cocaine": 
In Gemfile: 
paperclip (~> 3.4.1) ruby depends on 
cocaine (~> 0.5.0) ruby 

cocaine (0.3.2) 

我的Rails服务器返回的消息:

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-03-22 21:50:05 -0400 
Served asset /application.js - 304 Not Modified (1ms) 
[2013-03-22 21:50:05] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true 

任何帮助吗?如果有帮助,我在github上有https://github.com/jeremybelcher/omrails

你可能还没有安装imagemagick,并没有在你的应用程序中指出它。

正如documentation说:

ImageMagick must be installed and Paperclip must have access to it. To ensure that it does, on your command line, run which convert (one of the ImageMagick utilities). This will give you the path where that utility is installed. For example, it might return /usr/local/bin/convert.

In development mode, you might add this line to config/environments/development.rb):

Paperclip.options[:command_path] = "/usr/local/bin/" 
+0

可惜的是并没有这样做。它工作正常,直到我尝试添加样式来调整上传时的图像大小。 – 2013-03-23 02:42:27

曾与同omrails分配完全一样的问题 - 重新启动我的机器固定我的问题。

我有这个问题,并通过在上传模型Paperclip.options[:command_path] = "YOUR_PATH_TO_IMAGE_MAGICK"(在我的情况image.rb)固定它:

(Windows 7中,轨道4 &红宝石2.0):

#Image Upload 
has_attached_file :image, 
    :command_path => 'C:\RailsInstaller\ImageMagick', 
    :styles => { :medium => "x300", :thumb => "x100" }, 
    :default_url => "xxxxx", 
    :storage => :s3, 
    :bucket => 'xxxxxx', 
    :s3_credentials => S3_CREDENTIALS 

仍在努力使其成为开发的条件&生产

要回答Rich Peck的问题,您不必直接将其添加到模型中 - 你可以将它添加到/config/environments/development.rb。这样它只会影响你的开发版本,而不会影响你的生产版本。

所以在我的情况,我只是说

Paperclip.options[:command_path] = 'C:\Program Files\ImageMagick-6.8.7-Q16'

到我的配置/环境/ development.rb文件的末尾和它的工作就像一个魅力。

1-我有同样的问题,我解决了它,当我配置动态链接器运行时绑定来创建必要的链接和缓存到最新的共享库使用ldconfig command

所以,你需要使用下面的命令:

sudo ldconfig /usr/local/lib 

其实,我建议使用步骤在how-to-install-image-magick-and-setup-paperclip重新安装ImageMagick的。

2 - 你需要在development.rb文件中添加以下代码:

Paperclip.options[:command_path] = "/usr/local/bin/"