If You do use awesome :) Paperclip library, and on application served by Passenger You get errors like:
Avatar /tmp/stream.1170.0 is not recognized by the 'identify' command.
most probably Passenger does not have setup environment and is missing a path. On FreeBSD identify
is placed in /usr/local/bin
and AFAIR this path is not included by default in PATH. As result Passenger can not find this utility.
You can try to setup environment for Passenger (Apache?) or just add in appropriate environment (in my case it was production.rb
):
Paperclip.options[:command_path] = "/usr/local/bin"
I hit the same problem not long ago. In my case it was Linux and a custom build of ImageMagick which ended up in /usr/local/bin. The solution is the same.
This issue has driven me mad. Thanx !!!
I spent a ton of time trying to figure out why Paperclip stopped working for me. Reinstalling ImageMagick didn’t help. But this did! Thank you so much for this post.
Thanks! I lost half a day trying to figure that one out.
Thanks for this.
Seems like this issue happens if you try to upload a file that isn’t an image. The solution there is not to specify any thumbnail styles if you’re uploading videos.
For windows, make sure you close down the rails server and any command prompt instances and restart them. The imagemagick install path in program files (the folder containing identify.exe) needs to be accessible in the PATH variable. To check type echo %PATH% in the command prompt. If the imagemagick installation folder shows, the rails app should function.
Thanks for the info! Much appreciated
@Joshua, Or you can tell paperclip to create thumbnail only if attachment is video.
has_attached_file :source,
:styles => {:custom => ‘120×68#’},
:url => ‘/videos/:id/:style/:basename.:extension’,
:path => ‘:rails_root/public/videos/:id/:style/:basename.:extension’,
:processors => lambda { |a| a.video? ? [ :video_thumbnail ] : [ :thumbnail ] }
Oops, pressed enter too quickly.
Add a simple video method:
def video?
[ ‘application/x-mp4’,
‘video/mpeg’,
‘video/quicktime’,
‘video/x-la-asf’].include?(source.content_type)
end
Original code from http://thewebfellas.com/blog/2009/2/22/video-thumbnails-with-ffmpeg-and-paperclip