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

3

13

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.

Ology answered 30/5, 2012 at 5:17 Comment(1)
I got it working but forgot to post the solution to here. I believe my problem was a name conflict. My file uploader was called FileUploader. Replacing it with an AttachmentUploader fixed (or so I think) the problem: "File Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: MiniMagick::Invalid" Unfortunately, I am not 100% certain now, it's been a year ago. If somebody runs into this problem with an uploader called FileUploader and fixes it with a differently named uploader, please confirm it here.Ology
P
18

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
Phlebotomize answered 24/7, 2012 at 6:43 Comment(4)
Thank you thank you! Was getting the same obscure "Failed to manipulate..." error and couldn't figure it out for hours. I installed ImageMagick using homebrew (I'm on a Mac) and you're solution of installing from source with those options worked like a charm. THANK YOU!!Prudential
Thanks Ivan for the detailed manual install. But I wanted to have it all working with ImageMagick installed via Homebrew, not manually. I did get it work, there is no error messages from MiniMagick. It's almost a year ago, and I forgot to post the solution here and I didn't make relevant notes in my git logs. My best guess: I believe the problem was a name conflict. See my comment to my own question above.Ology
I've rebuilt ImageMagick from source as per these instructions on top of the IM installed by brew (needed to add JPEG support), everything worked. @Ology I think you should mark this very good answer as accepted.Hellion
sudo apt-get install libjpeg62 worked for me, thanks.Consolidate
J
11

Feb 2014

I just ran into this issue and was all excited to spend my day compiling ImageMagick from source, but figured I'd try a brew update && brew upgrade imagemagick first.

==> Upgrading 1 outdated package, with result:
imagemagick 6.8.7-7

It worked.

Jeaz answered 1/3, 2014 at 16:22 Comment(1)
much easier solutionConfidante
D
0

First make sure your machine has all the compilers and tools it needs.

sudo yum groupinstall "Development Tools"
sudo yum install rpmdevtool libtool-ltdl-devel

sudo yum install ImageMagick-devel
Deceased answered 19/12, 2017 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.