0

undefined method 'size' for nil:NilClass occurs at MiniMagick::Utilities.which('mogrify').size in def choose_processor mini_magick (3.7.0) lib/mini_magick.rb.

It seems like mini_magick gem doesn't find my ImageMagick.

I am using Windows 7, mini_magick 3.7.0, Rails 4.0.2, Ruby 2.0.0p353, ImageMagick 6.8.8-1

code:

version :normal do
   process resize_to_limit: [1028,850]
end

ImageMagick is installed:

C:\Users>convert -version
Version: ImageMagick 6.8.8-1 Q16 x64 2013-12-25 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsv
g tiff webp xml zlib 

Please help. Thanks in advance.

Ivan Wang
  • 8,306
  • 14
  • 44
  • 56

1 Answers1

0

You need to make sure that ImageMagick, specifically the command mogrify, is on your PATH environment variable at the point where MiniMagick is first called. Depending on how you start your application, it is easy to end up with a different path than what you have within your command prompt.

To debug the issue, inspect the value of ENV['PATH'] just before the place where the error is occurring. You will probably see that ImageMagick's folder is missing from your path.

You will then want to add a line like the following to application.rb, environments/production.rb, or some other appropriate place:

ENV['PATH'] += File::PATH_SEPARATOR + 'C:\path\to\imagemagick'

This will guarantee that your path contains the correct location of ImageMagick.

pdg137
  • 3,552
  • 2
  • 21
  • 24
  • Interesting answer. How would you go about this debugging? Considering my development environment already has a line: ENV['PATH'] = "/usr/local/Cellar/postgresql/9.2.4/bin:#{ENV['PATH']}" to deal with the fact that postgreSQL needs to be properly picked up (Apple pre-installs in a different place) – Jerome Mar 29 '14 at 20:17
  • This question was from a Windows user, while it appears that you are on Mac OS. I used File::PATH_SEPARATOR to support either OS; you can safely do it that way or just extend the line you already added to include the path to Imagemagick on your development machine. – pdg137 Mar 31 '14 at 18:49