我正在将我的应用程序升级到 Ruby 1.9 上的 Rails 3.2。我不得不放弃attachment_fu
. Carrierwave 似乎是明显的替代品。在这个阶段,我正在将文件上传到文件系统(还没有云文件)。
我在 Lion,XCode 4.3.2,安装了命令行工具。运行:
$ brew doctor
# Your system is raring to brew.
我可以在此配置中上传和调整图像大小:
我可以在新配置中上传图片:
(后跟
$ 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/