Remove unncessary error raised by paperclip - filename is not recognized by the 'identify' command.

Posted by kgpdeveloper on Stack Overflow See other posts from Stack Overflow or by kgpdeveloper
Published on 2010-04-15T09:22:10Z Indexed on 2010/05/10 23:34 UTC
Read the original article Hit count: 254

Filed under:
|
|

I've been searching on how to solve this issue but could not find any real and working solution.

User model:

validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/gif']

Unnecessary error shows up when invalid file type is uploaded:

Avatar /tmp/sample,23283,0.txt is not recognized by the 'identify' command.

Server details: Ubuntu and Debian

which identify results to /usr/bin/identify

Specifying command path does not solve the issue:

Paperclip.options[:command_path] = "/usr/bin"

Any ideas?

I looked at geometry.rb file and there seems to be something wrong with it.

def self.from_file file
  file = file.path if file.respond_to? "path"
  geometry = begin
               Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
             rescue PaperclipCommandLineError
               ""
             end
  parse(geometry) ||
    raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command."))
end

Let me know if anyone has solved the same issue and how. Many thanks.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails