MiniMagick error. undefined method 'resize'

2k views Asked by At

This error only happens when executed by the Ruby on Rails server.

I've tried bypassing Carrierwave's resize option by implementing my own but it has the same result.

when I run a script from command line (in which I require the 'mini_magick' gem). It all works flawlessly.

the MiniMagick gem seems to be installed correctly and to be honest I'm kinda out of ideas to tackle this problem.

some versions (not sure if usefull or not):

  • ruby - 1.9.3p545
  • rails - 4.1.1
  • mini_magick - 4.0.1
  • ImageMagick - 6.9.0-0 Q16

Any help is appreciated.

-edit, I'm using windows 8.1

example code:

require 'mini_magick'

filename = 'test.jpg'
image = MiniMagick::Image.open(filename)
image.resize "1000x1000"
image.format "png"
image.write "test.png"

The code above works flawlessly when executed from cmd.

thumb = MiniMagick::Image.open(i.image.path)
thumb.resize "200*200"

code snippet above throws error in RoR when placed in a controller (Create)

alternatively, uncommenting the resize option directly from carrierwave throws the exact same error.

# version :thumb do
  #   process :resize_to_fill => [200, 200]
# end

Also a little note: I've disabled minimagicks validations to figure out what causes the error it threw at that time:

Failed to manipulate with MiniMagick, maybe it is not an image? original error: executable not found: "identify"

I hope this clears a few things up.

-edit

I've decided to leave windows as a dev platform and switch to linux as a dev platform. fixed all of my issues (In hindsight my error was probably due to some lacking dependencies on the imagemagick side).

3

There are 3 answers

0
Steve Swett On

I experienced a similar problem recently with the following environment:

  • Windows 8.1
  • Ruby 2.1.5p273
  • Ruby Dev Kit 2.1.5
  • Rails 4.2.0.beta4
  • carrierwave 0.10.0
  • mini_magick 4.0.1
  • ImageMagick6.9.0-Q16 installed at C:\ImageMagick-6.9.0-Q16

In the rails console within RubyMine, I would get:

executable not found: "identify"

after keying in just two things:

filename = 'test.jpg'
image = MiniMagick::Image.open(filename)

One of the steps was to add C:\ImageMagick-6.9.0-Q16 to my Windows PATH environment variable. At first, that didn't help. However, after closing and re-opening RubyMine, the problem went away -- I assume because the change to the PATH env var (done with an independent Windows command prompt) didn't affect the RubyMine IDE environment.

0
Yuya Kitajima On

executable not found: "identify"

This is an error message from MiniMagick (Source code). I guess, as the error message says, your server cannot find executable "identify".

Make sure that your ENV['PATH'] has the path to where the "identify" exists.

0
spaceman On

I'm running into the same problem.

it works flawlessly on my localhost, but on the server (windows 2012), it only works as a rake task. when run inside the application, then it fails saying

NoMethodError (undefined method `resize' for #<MiniMagick::Image:0x28c3260>):

Unfortunately, the path variable is set...

I got it to work by doing the minimagick-stuff inside the model instead of the controller.... nasty workaround.