载波错误消息:无法使用MiniMagick进行操作,也许它不是图像? [英] Carrierwave Error Msg: Failed to manipulate with MiniMagick, maybe it is not an image?

查看:84
本文介绍了载波错误消息:无法使用MiniMagick进行操作,也许它不是图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am upgrading my app to Rails 3.2 on Ruby 1.9. I had to drop attachment_fu. Carrierwave seemed the obvious replacement. At this stage I am uploading files to the file system (no cloud files, yet).

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

I am on Lion, XCode 4.3.2, Command Line Tools installed. Running:

$ brew doctor
# Your system is raring to brew.

我可以在以下配置中上载图像并调整其大小:

I can upload and resize images in this configuration:


  • 轨道3.1.4

  • 红宝石1.8.7

  • 载波0.5.8

  • mini_magick 3.4

  • rails 3.1.4
  • ruby 1.8.7
  • carrierwave 0.5.8
  • mini_magick 3.4

我可以在新配置中上传图片:

I can upload images in the new configuration:


  • 轨道3.2.3

  • 红宝石1.9.3(或1.9.2)

  • 载波0.6 .2

(后跟 $ bundle update ),但使用 mini_magick 返回此错误消息:

(followed by $ bundle update) but resizing using mini_magick returns this error message:

"File Failed to manipulate with MiniMagick, maybe it is not an image Original Error: MiniMagick::Invalid", where File is the carrierwave uploader.

FileUploader包含:

The FileUploader contains:

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

我的附件类(带有 mount_uploader:file, FileUploader )是 Portrait ReferenceLetter 和其他附件类的父类。每个附件类都从 Attachment 继承,即为:polymorphic =>。 true 属于:attachable (用户),而 has_many:portraits :reference_letters 等。:as => :attachable

My Attachment class (with the mount_uploader :file, FileUploader) is a parent of Portrait, ReferenceLetter, and other attachment kind of classes. Each of the attachment classes inherits from the Attachment, is :polymorphic => true, and belongs_to :attachable (User) which, in turn, has_many :portraits, :reference_letters, etc. :as => :attachable.

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

None of these worked (linked from carrierwave's known issues page):

为什么此RMagick调用会产生分段错误?

我不想按照此处的建议手动安装ImageMagick:

I didn't want to install ImageMagick manually as suggested here:

carrierwave + mini_magick宝石=不是图像错误

我正在使用自制软件。帮助将是极好的。谢谢。

I'm using Homebrew. Help would be fantastic. Thanks.

推荐答案

今天正在以相同的错误进行战斗。问题不在mini_magick中,问题出在imagemagick中的 DELEGATES 选项中

Was fighting with the same error today. The problem was not in mini_magick, the problem is in DELEGATES options in your 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值

But in my case key DELEGATES had only xml and zlib values

DELEGATES     xml zlib

解决方案是从源代码安装imagemagick并添加参数到./configure

The solution was to install imagemagick from source and add params to ./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

You can find installations instructions for MacOS here http://www.imagemagick.org/script/advanced-unix-installation.php

更新

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

For some reasons, a system can be without jpeg convert libraries. To fix this you can install imagemagick using apt-get or ppa with all needed dependencies or try to install manualy

sudo apt-get install libjpeg62

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

更新01/26/2013

要安装 libpng

点击此链接 http://www.libpng.org/pub/png/libpng.html 并找到源代码块。
复制最新版本的链接

Follow this link http://www.libpng.org/pub/png/libpng.html and find "Source Code" block. Copy a link for a latest version

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支持的另一种方法

Another way to get JPEG support

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

这篇关于载波错误消息:无法使用MiniMagick进行操作,也许它不是图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆