0
votes

A few system details:

  • Mac OS X Lion 10.7.2, Rails 3, Paperclip gem.
  • ImageMagick 6.7.3-0, binaries installed using MacPorts in /opt/local/bin.
  • Using WEBrick in development environment.

I'm trying to upload photos that should get resized down into thumbnails. When I do so, the original uploaded file is saved and can be accessed via HTTP correctly. When I try to accessed the thumbnail version, I get this error:

Routing Error
No route matches "[file_URL]"

Before that, when uploading a valid PNG file, I see this error in my WEBrick log:

[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /var/folders/n4/62q22gb52rjd0h13cx_j8vv40000gq/T/stream20111020-24984-17560xt-0.png is not recognized by the 'identify' command.>

Doing which identify outputs:

/opt/local/bin/identify

Calling identify with the path of the uploaded file correctly identifies the file as a PNG file.

I confirmed rails server starts the development environment. I added the following in config/environments/development.rb:

Paperclip.options[:command_path] = "/opt/local/bin"

My Photo model has the following:

class Photo < ActiveRecord::Base
  has_attached_file :file, :default_style => :view, :styles => {
    :view => { :geometry => '520x390>', :format => 'jpg' },
    :preview => { :geometry => '160x120>', :format => 'jpg' } }
  validates_attachment_content_type :file,
    :content_type => [ 'image/jpeg', 'image/pjpeg', 'image/png' ]
end

My Photos controller:

class PhotosController < ApplicationController
  # ...
  def create
    @photo = Photo.create params[:photo]
  end
end

Like I said, I can access the original images in the URL path system/files/:id/original, but the resized versions I want aren't accessible and are not found in the filesystem. WEBrick's log suggest Paperclip can't even have ImageMagick identify the images before resizing them.

Any ideas? Thanks in advance!

1
The problem occurs when the file is originally uploaded and paperclip tries to process it (NotIdentifiedByImageMagickError). This question could be a duplicate: stackoverflow.com/questions/1623948/…Jonathan Julian

1 Answers

0
votes

This may be a duplicate question, as stated above, but this problem was caused by a recent bug in ImageMagick 6.7.3-0 fixed soon after in 6.7.3-1. MacPorts has also been updated with the new release.

In 6.7.3-0, stating the frame number in the file path (e.g. identify /path/to/file.png[0]) caused ImageMagick to segfault ("Segmentation fault 11"). Paperclip specified the frame number to ensure its processing the first frame or page of an image file.

The new release of ImageMagick solved this problem. The bug was mentioned on MacPorts:

https://trac.macports.org/ticket/31643