refinerycms image not loading - dragonfly error
Asked Answered
D

4

8

I'm working on developing a refinerycms rails app that was working good locally and now i've moved it to my VPS and I was having issues with images that i uploaded through refinerycms not loading and i've been reading that i needed to upgrade my version of imagemagick. I upgraded from 6.2.8 to 6.7.8. Now the images all load on some pages, but not on the admin side.

What is causing this issue? Here's the stacktrace of the error.

Dragonfly::Shell::CommandFailed (Command failed (convert '/var/www/vhosts/tomstestsite.us/PersonalTrainingKT/public/system/refinery/images/2012/06/03/16_36_48_339_pamLemke_after.jpg' '-resize' '225x255>' '/tmp/dragonfly20120705-7812-1xb3pce') with exit status 127):
  dragonfly (0.9.12) lib/dragonfly/shell.rb:29:in `raise_shell_command_failed'
  dragonfly (0.9.12) lib/dragonfly/shell.rb:23:in `run'
  dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:17:in `convert'
  dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:103:in `convert'
  dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:27:in `resize'
  dragonfly (0.9.12) lib/dragonfly/image_magick/processor.rb:87:in `thumb'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `call'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `catch'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `block in call_last'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `each'
  dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `call_last'
  dragonfly (0.9.12) lib/dragonfly/processor.rb:5:in `process'
  dragonfly (0.9.12) lib/dragonfly/job.rb:79:in `apply'
  dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `block in apply'
  dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `each'
  dragonfly (0.9.12) lib/dragonfly/job.rb:253:in `apply'
  dragonfly (0.9.12) lib/dragonfly/response.rb:25:in `to_response'
  dragonfly (0.9.12) lib/dragonfly/server.rb:43:in `block in call'
  dragonfly (0.9.12) lib/dragonfly/server.rb:39:in `catch'
  dragonfly (0.9.12) lib/dragonfly/server.rb:39:in `call'
  dragonfly (0.9.12) lib/dragonfly/middleware.rb:11:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
  rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
  rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
  rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
  rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/reloader.rb:65:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.3) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.3) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  actionpack (3.2.3) lib/action_dispatch/middleware/static.rb:62:in `call'
  railties (3.2.3) lib/rails/engine.rb:479:in `call'
  railties (3.2.3) lib/rails/application.rb:220:in `call'
  railties (3.2.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
  passenger (3.0.11) lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  passenger (3.0.11) lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
  passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:275:in `block in handle_spawn_application'
  passenger (3.0.11) lib/phusion_passenger/utils.rb:479:in `safe_fork'
  passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application'
  passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:180:in `start'
  passenger (3.0.11) lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
  passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:219:in `block (2 levels) in spawn_rails_application'
  passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
  passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:214:in `block in spawn_rails_application'
  passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
  <internal:prelude>:10:in `synchronize'
  passenger (3.0.11) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
  passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
  passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
  passenger (3.0.11) lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  passenger (3.0.11) lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  passenger (3.0.11) helper-scripts/passenger-spawn-server:99:in `<main>'

UPDATE

I've added the code below to my config/application.rb file as suggested here and it helped some of the files show up, and but i'm still unable to upload a file through the app and part of this stacktrace is shown below.

config/application.rb contains this

initializer 'override-image-magick-paths', :after => 'attach-refinery-images-with-
    dragonfly' do
      app=Dragonfly[:refinery_images]
      app.configure_with(:imagemagick)
      app.configure do |c|
        c.convert_command = "/usr/local/bin/convert"          # defaults to "convert"
        c.identify_command = "/usr/local/bin/identify"        # defaults to "identify"
      end
    end

stacktrace

 Dragonfly::Shell::CommandFailed (Command failed (identify '/tmp/RackMultipart20120708-20096-4m1k9j') with exit status 127):
      dragonfly (0.9.12) lib/dragonfly/shell.rb:29:in `raise_shell_command_failed'
      dragonfly (0.9.12) lib/dragonfly/shell.rb:23:in `run'
      dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:34:in `raw_identify'
      dragonfly (0.9.12) lib/dragonfly/image_magick/utils.rb:24:in `identify'
      dragonfly (0.9.12) lib/dragonfly/image_magick/analyser.rb:44:in `format'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `call'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:39:in `block (2 levels) in call_last'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `catch'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:38:in `block in call_last'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `each'
      dragonfly (0.9.12) lib/dragonfly/function_manager.rb:37:in `call_last'
      dragonfly (0.9.12) lib/dragonfly/analyser.rb:25:in `analyse'
      dragonfly (0.9.12) lib/dragonfly/job.rb:247:in `analyse'
Diarrhea answered 6/7, 2012 at 4:30 Comment(5)
Is /usr/local/bin in your $PATH?Distracted
Yesp it's in my path. I'll post my entire path when i get home.Diarrhea
Well you can optionally set $magick_home in your env, but I don't think that will solve it. Whatever params Dragonfly is sending to identify it doesn't like. Try to save the model from the rails console and debug from there, I'm curious to see the outputted parameters to the identify binary.Distracted
Can you provide me detailed steps to do that? I'm a rails rookie and not sure i follow exactly what i need to do.Diarrhea
Well in that case, when you do the upload you should see the output in your terminal of what the command is. I'll post an example of a model I have that is working.Distracted
D
5

I created a symbolic link from /usr/bin/convert -> /usr/local/bin/convert and from /usr/bin/identify -> /usr/local/bin/identify and that seemed to solve my problems.

$ cd /usr/bin
$ ln -s /usr/local/bin/convert convert
$ ln -s /usr/local/bin/identify identify 

I'm assuming that dragonfly is still not picking up my location of convert and identify even though i specified it in my config/application.rb file.

Diarrhea answered 9/7, 2012 at 17:29 Comment(4)
This worked for me too. Another way is to change the path in lib/dragonfly/image_magick/utils.rb, configurable_attr :convert_command, "/usr/local/bin/convert" configurable_attr :identify_command, "/usr/local/bin/identify" but I like this way better. Cleaner.Edmon
Actually, it looks like you got that backwards. You're creating a symbolic link FROM /usr/local/bin/... TO /usr/bin/... This means that this shouldnt be necessary on e.g. Ubuntu, where apt installs convert/identify to these paths automaticallyEdmon
From all the research i've looked at with this problem, it seems to be a centos issue.Diarrhea
It also happened to me in OSX Lion. Not the RefineryCMS bit, but the underlying Dragonfly issue.Edmon
H
6

I simply reinstalled imagemagick and it worked.

Hodess answered 5/5, 2013 at 4:30 Comment(0)
D
5

I created a symbolic link from /usr/bin/convert -> /usr/local/bin/convert and from /usr/bin/identify -> /usr/local/bin/identify and that seemed to solve my problems.

$ cd /usr/bin
$ ln -s /usr/local/bin/convert convert
$ ln -s /usr/local/bin/identify identify 

I'm assuming that dragonfly is still not picking up my location of convert and identify even though i specified it in my config/application.rb file.

Diarrhea answered 9/7, 2012 at 17:29 Comment(4)
This worked for me too. Another way is to change the path in lib/dragonfly/image_magick/utils.rb, configurable_attr :convert_command, "/usr/local/bin/convert" configurable_attr :identify_command, "/usr/local/bin/identify" but I like this way better. Cleaner.Edmon
Actually, it looks like you got that backwards. You're creating a symbolic link FROM /usr/local/bin/... TO /usr/bin/... This means that this shouldnt be necessary on e.g. Ubuntu, where apt installs convert/identify to these paths automaticallyEdmon
From all the research i've looked at with this problem, it seems to be a centos issue.Diarrhea
It also happened to me in OSX Lion. Not the RefineryCMS bit, but the underlying Dragonfly issue.Edmon
L
1

You may have to provide the full path to convert:

config/initializers/dragonfly.rb:

app.configure do |c|
  c.convert_command = "/usr/bin/convert"
end

Change /usr/bin/convert to the correct path to convert, which you can find out by running whereis convert on your VPS shell.

More details in the documentation.

Lawrencelawrencium answered 6/7, 2012 at 4:50 Comment(2)
you're probably right on the dragonfly part, but how can i do this so refinery picks it up? I keep getting a passenger error page with the code that you've provided me.Diarrhea
Refinery can pick it up like so: github.com/resolve/refinerycms/issues/1781#issuecomment-6816678Rosaleerosaleen
D
1

Try installing the refinery-images gem:

Gemfile:
   gem 'refinerycms-page-images', '~>1.0.3' //refinery v1 compatible (v2 available also)

Then in your model:

belongs_to :imagesizeyouwant, :class_name => 'Image'

If you look at the Image class you'll see a pretty nice set up for handling images. You can add image sizes in Refinery's Settings page in the admin tool. If you have a custom engine, just change :imagesizeyouwant to that size (mine was :thumbnail).

When you post the image, look at the output of the identify command and try to run it on your own. Chances are your system has different parameters it uses for ImageMagick binaries, or that the dimensions being sent to it are not understood. Try posting the output of the actual command Dragonfly is calling in the shell so we can take a better look.

Distracted answered 11/7, 2012 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.