在Spree的管理界面中创建图片时出现了Paperclip::NotIdentifiedByImageMagickError错误。

3

我第一次尝试设置Spree。一切都进行得很顺利,直到我遇到了图片上传的问题。我已经使用Homebrew在Mac OSX Mountain Lion上安装了Imageamgick。上传任何图像时都会出现以下错误。

Paperclip::NotIdentifiedByImageMagickError in Spree::Admin::ImagesController#create

    Command :: identify -format %wx%h :file
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/fq/9g_6hmg513g6137rb6sbghw00000gn/T/stream20121005-26943-16883d4.png is not recognized by the 'identify' command.>

Paperclip::NotIdentifiedByImageMagickError (/var/folders/fq/9g_6hmg513g6137rb6sbghw00000gn/T/stream20121005-26943-16883d4.png is not recognized by the 'identify' command.):
  paperclip (2.7.1) lib/paperclip/geometry.rb:29:in `from_file'
  spree_core (1.2.0) app/models/spree/image.rb:35:in `find_dimensions'
  activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__1794851703999987262__post_process__1580526166879208018__callbacks'

当我在命令行中运行identify命令时,会得到以下输出。
    Image Settings:
  -alpha option        on, activate, off, deactivate, set, opaque, copy
                       transparent, extract, background, or shape
  -antialias           remove pixel-aliasing
  -authenticate password
                       decipher image with this password
  -channel type        apply option to select image channels
  -colorspace type     alternate image colorspace
  -crop geometry       cut out a rectangular region of the image
  -define format:option
                       define one or more image format options
  -density geometry    horizontal and vertical density of the image
  -depth value         image depth
  -extract geometry    extract area from image
  -features distance   display image features (e.g. contrast, correlation)
  -format "string"     output formatted image characteristics
  -fuzz distance       colors within this distance are considered equal
  -gamma value         of gamma correction
  -interlace type      type of image interlacing scheme
  -interpolate method  pixel color interpolation method
  -limit type value    pixel cache resource limit
  -monitor             monitor progress
  -ping                efficiently determine image attributes
  -quiet               suppress all warning messages
  -regard-warnings     pay attention to warning messages
  -respect-parentheses settings remain in effect until parenthesis boundary
  -sampling-factor geometry
                       horizontal and vertical sampling factor
  -seed value          seed a new sequence of pseudo-random numbers
  -set attribute value set an image attribute
  -size geometry       width and height of image
  -strip               strip image of all profiles and comments
  -unique              display the number of unique colors in the image
  -units type          the units of image resolution
  -verbose             print detailed information about the image
  -virtual-pixel method
                       virtual pixel access method

Image Operators:
  -negate              replace every pixel with its complementary color 

Miscellaneous Options:
  -debug events        display copious debugging information
  -help                print program options
  -list type           print a list of supported option arguments
  -log format          format of debugging information
  -version             print version information

By default, the image format of `file' is determined by its magic
number.  To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps).  Specify 'file' as
'-' for standard input or output.

非常感谢您的帮助。

谢谢, Cory

3个回答

12

我的错误是 - “Paperclip::NotIdentifiedByImageMagickError in Spree::Admin::ImagesController

几天前我解决了这个错误。

在那之前,我尝试了以下方法:

  • 更新XCode(使用命令行工具)
  • 更新Imagemagick(我尝试从源代码和二进制模块进行更新)
  • 更新MacPort
  • 使用Brew(刷新所有与Imagemagic相关的依赖项,使用“brew doctor”),而不是MacPort
  • 重新安装所有使用Imagemagick的gem
  • Bundle update
  • 等等

当然,我在production.rb文件中使用“Paperclip :: Attachment.default_options [: command_path]”选项,指向Imagemagick bin文件夹。

我多次从头到尾重复执行上述步骤,但是没有任何帮助。

顺便说一句,在所有情况下,我都能够使用测试图片的“convert”,“identify”和“display”正常工作,但在我的Rails应用程序(Spree应用程序)中不能。

我深入挖掘并尝试在rails控制台内进行研究

Paperclip.run("identify", "-format %m :file", :file => "/path/to/image”) 

就像 Paperclip 一样。只有这个命令的新格式(cocaine 0.4):

Paperclip.run("identify", "-format %m /path/to/image")

非常好!

结果我发现。 我尝试在我的Gemfile中将其降级到cocaine 0.3.2,然后我的Spree应用程序就正常工作了!

我只需要使用cocaine 0.3.2而不是0.4就可以了!!!


谢谢Leonid,问题已经解决了。你是否向Spree和/或cocaine项目提交了错误报告? - Cory Gwin
1
你可能可以升级到Paperclip 2.8来解决这个问题。 - Leo Lukin
9
如果这个回答在给出答案前没有讲述那么长的故事,它会更好。请先直接给出答案,如果您认为有必要提供一些背景信息,可以在之后提供。 - coreyward

0

我也遇到了一个问题,当图像文件不存在于公共文件夹中时。
我只是复制了一个随机文件与相同的名称,一切都开始工作。

parepclip 2.7.5 cocain 0.3.2

0

检查 png 格式是否在 identify 的已编译格式列表中:

identify -list format

如果不是,您可能需要使用这些选项重新编译它:

./configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes

它似乎是PNG24* PNG rw- 不透明的24位RGB(zlib 1.2.5) PNG32* PNG rw- 不透明或透明的32位RGBA PNG8* PNG rw- 具有可选二进制透明度的8位索引 - Cory Gwin
我通过Homebrew升级了我的ImageMagick安装,现在它可以正常工作了。 - badams

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接