1

I just installed paperclip into my app to upload images, and everything was working well until I tried to add the styles to make the image resize. (I can upload images fine before I add this code)

on pins.rb:

has_attached_file :image, styles: { medium: "300x300>" }

I then added the class to on _pin.html.rb:

<td><%= image_tag pin.image(:medium) %></td>

But now, when I try and upload an image, I get the error:

Paperclip::Errors::NotIdentifiedByImageMagickError

When I remove the styles, it works fine (alebit not resized), but something in the resizing is messing it all up. I tried different file types and filenames. I have searched for this error on google, and all the solutions aren't working for me. The most popular was to downgrade Cocaine, but when I try that it I get the message:

Bundler could not find compatible versions for gem "cocaine":
In Gemfile:
paperclip (~> 3.4.1) ruby depends on
cocaine (~> 0.5.0) ruby

cocaine (0.3.2)

My rails server is returning the message:

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-03-22 21:50:05 -0400
Served asset /application.js - 304 Not Modified (1ms)
[2013-03-22 21:50:05] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

Any help? I have it on github at https://github.com/jeremybelcher/omrails if that helps.

Paolo
  • 20,112
  • 21
  • 72
  • 113

5 Answers5

2

To answer Rich Peck's question, you don't have to add it into the model directly - you can add it into /config/environments/development.rb. That way it'll only affect your dev version and not your production version.

So in my case, I just added

Paperclip.options[:command_path] = 'C:\Program Files\ImageMagick-6.8.7-Q16'

to the end of my config/environments/development.rb file and it worked like a charm.

Josiah
  • 114
  • 11
1

Had the exact same issue with the same omrails assignment - rebooting my machine fixed my issue.

Louise
  • 11
  • 1
0

You probably haven't installed imagemagick and haven't pointed to it in your application.

As stated in the documentation:

ImageMagick must be installed and Paperclip must have access to it. To ensure that it does, on your command line, run which convert (one of the ImageMagick utilities). This will give you the path where that utility is installed. For example, it might return /usr/local/bin/convert.

In development mode, you might add this line to config/environments/development.rb):

Paperclip.options[:command_path] = "/usr/local/bin/"
Zippie
  • 6,018
  • 6
  • 31
  • 46
0

I had this problem, and fixed it by including Paperclip.options[:command_path] = "YOUR_PATH_TO_IMAGE_MAGICK" in the upload model (in my case image.rb):

(Windows 7, Rails 4 & Ruby 2.0):

#Image Upload 
has_attached_file :image,
    :command_path => 'C:\RailsInstaller\ImageMagick',
    :styles => { :medium => "x300", :thumb => "x100" },
    :default_url => "xxxxx",
    :storage => :s3,
    :bucket => 'xxxxxx',
    :s3_credentials => S3_CREDENTIALS

Still working on making it conditional for development & production

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
0

1- I have the same issue, and I solved it, when i configure the dynamic linker run-time bindings to create the necessary links and cache to the most recent shared libraries using the ldconfig command.

So you need to use the following command:

sudo ldconfig /usr/local/lib

Actually, I advice to re-install imagemagick using steps at how-to-install-image-magick-and-setup-paperclip.

2- You need to add the following code in development.rb file:

Paperclip.options[:command_path] = "/usr/local/bin/"
Mohamed Yakout
  • 2,868
  • 1
  • 25
  • 45