Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carrierwave Error Msg: Failed to manipulate with MiniMagick, maybe it is not an image?

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).

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:

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

I can upload images in the new configuration:

  • rails 3.2.3
  • ruby 1.9.3 (or 1.9.2)
  • carrierwave 0.6.2

(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.

The FileUploader contains:

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

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.

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

Why is this RMagick call generating a segmentation fault?

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

carrierwave + mini_magick gems = not an image error

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

like image 764
Arta Avatar asked May 30 '12 05:05

Arta


1 Answers

Was fighting with the same error today. The problem was not in mini_magick, the problem is in DELEGATES options in your imagemagick

If you run

convert -list configure

you should have something like this

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

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

DELEGATES     xml zlib

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

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

UPDATE

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

See more info here https://askubuntu.com/questions/211627/how-to-add-support-for-the-jpeg-image-format

UPDATE 01/26/2013

To install libpng

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

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
like image 100
Ivan Linko Avatar answered Oct 24 '22 00:10

Ivan Linko