ruby-on-rails-3.2 - Carrierwave Error Msg : Failed to manipulate with MiniMagick, 也许不是图像?

标签 ruby-on-rails-3.2 carrierwave ruby-1.9 minimagick

我正在将我的应用程序升级到 Ruby 1.9 上的 Rails 3.2。我不得不放弃attachment_fu . Carrierwave 似乎是明显的替代品。在这个阶段,我正在将文件上传到文件系统(还没有云文件)。

我在 Lion,XCode 4.3.2,安装了命令行工具。运行:

$ brew doctor
# Your system is raring to brew.

我可以在此配置中上传和调整图像大小:
  • 导轨 3.1.4
  • ruby 1.8.7
  • 载波 0.5.8
  • mini_magick 3.4

  • 我可以在新配置中上传图片:
  • 导轨 3.2.3
  • ruby 1.9.3(或 1.9.2)
  • 载波 0.6.2

  • (后跟 $ bundle update )但使用 mini_magick 调整大小返回此错误消息:
    "File Failed to manipulate with MiniMagick, maybe it is not an image Original Error: MiniMagick::Invalid", where File is the carrierwave uploader.
    

    FileUploader 包含:
    include CarrierWave::MiniMagick
    def store_dir .. end # the shipped default 
    process :resize_to_limit => [500, 600]
    

    我的 Attachment 类(带有 mount_uploader :file, FileUploader )是 Portrait 的父类, ReferenceLetter , 和其他附件类。每个附件类都继承自 Attachment , 是 :polymorphic => true , 和 belongs_to :attachable (用户)反过来,has_many :portraits , :reference_letters:as => :attachable .

    这些都不起作用(从carrierwave的已知问题页面链接):

    Why is this RMagick call generating a segmentation fault?

    我不想按照这里的建议手动安装 ImageMagick:

    carrierwave + mini_magick gems = not an image error

    我正在使用自制软件。帮助会很棒。谢谢。

    最佳答案

    今天正在与同样的错误作斗争。问题不在 mini_magick,问题在 代表 imagemagick 中的选项

    如果你跑

    convert -list configure
    

    你应该有这样的东西
    Name          Value
    -----------------------------------------------------------------
    ...
    CONFIGURE     ./configure  '--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' '--disable-shared'
    CONFIGURE_PATH /usr/local/etc/ImageMagick/
    COPYRIGHT     Copyright (C) 1999-2012 ImageMagick Studio LLC
    ...
    DELEGATES     bzlib djvu fontconfig freetype gvc jpeg jng jp2 lcms lqr openexr png rsvg tiff x11 xml zlib
    ...
    VERSION       6.7.5
    

    但在我的情况下,关键 DELEGATES 只有 xml 和 zlib 值
    DELEGATES     xml zlib
    

    解决方案是 从源代码安装 imagemagick 并将参数添加到 ./configure
    1. wget http://www.imagemagick.org/download/ImageMagick.tar.gz
    2. tar xvfz ImageMagick.tar.gz
    3. cd ImageMagick
    4. ./configure --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 --disable-shared
    5. make
    6. sudo make install
    7. sudo ldconfig /usr/local/lib
    8. run again "convert -list configure" and look at changes
    

    您可以在此处找到 MacOS 的安装说明 http://www.imagemagick.org/script/advanced-unix-installation.php

    更新

    由于某些原因,系统可能没有 jpeg 转换库。要解决此问题,您可以使用 apt-get 或 ppa 安装 imagemagick 以及所有需要的依赖项,或者尝试手动安装
    sudo apt-get install libjpeg62
    

    在此处查看更多信息 https://askubuntu.com/questions/211627/how-to-add-support-for-the-jpeg-image-format

    2013 年 1 月 26 日更新

    安装 libpng

    点击此链接http://www.libpng.org/pub/png/libpng.html并找到“源代码” block 。
    复制最新版本的链接
    1. wget http://download.sourceforge.net/libpng/libpng-1.5.13.tar.gz
    2. tar xvfz libpng-1.5.13.tar.gz 
    3. cd libpng-1.5.13/
    4 ./configure
    5. make
    6. sudo make install
    7. Rebuild imagemagick
    

    获取 的另一种方式JPEG 支持
    1. curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz
    2. tar zxvf jpegsrc.v8c.tar.gz
    3. cd jpeg-8c/
    4. ./configure
    5. make
    6. sudo make install
    7. Rebuild imagemagick
    

    关于ruby-on-rails-3.2 - Carrierwave Error Msg : Failed to manipulate with MiniMagick, 也许不是图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810356/

    相关文章:

    ruby-on-rails - 使用 Heroku 显示存储在 Amazon S3 上的图像

    ruby - 是否有可能在 Ruby 1.9 中获得哈希键的后继和前导?

    ruby-on-rails - 不支持从 define_method() 定义的方法隐式传递 super 参数

    ruby - IRB - Ruby 1.9.x 哈希语法 : {if: true} is not equal to {:if => true}

    ruby-on-rails - rails 3.2 使用的默认 gem

    javascript - 将值从 JQuery 传递到我的模型并更新数据库

    ruby-on-rails - 如何在重定向时显示 Rails flash 通知?

    ruby-on-rails - 载波的多个默认图像

    postgresql - Rails 3.2 + pg gem : load path issue

    ruby-on-rails - CarrierWave中未定义的方法规模