RubyNewbie
RubyNewbie

Reputation: 547

Paperclip::Errors::NotIdentifiedByImageMagickError + Heroku

I currently have an application using paperclip that allows users to upload their creatives. This has worked flawless thus far when it comes to a user uploading an image file. We have since tested to upload a .mov file and I get this error:

Creative Paperclip::Errors::NotIdentifiedByImageMagickError

The weird thing, this error is only generated on Heroku. I can upload .mov files just fine on my local host.

My Current Gem Setup:

paperclip (3.4.1, 3.4.0)
paperclip-aws (1.6.7, 1.6.6)
paperclip-ffmpeg (0.10.2)
cocaine (0.5.1, 0.4.2)

Event.rb

has_attached_file :creative, 
                :processors => [:ffmpeg],
                :styles => { 
                  :thumb => [:geometry => "250x150", :format => 'png'], 
                  :custcreative => [:geometry => "275x75", :format => 'png'], 
                  :creativepreview => ["275x195",:png] 
                           },
                :url => "***", 
                :path => "***",
                :s3_domain_url => "***",
                :storage => :s3,
                :s3_credentials => Rails.root.join("config/s3.yml"),
                :bucket => '***',
                :s3_permissions => :public_read,
                :s3_protocol => "http",
                :convert_options => { :all => "-auto-orient" },
                :encode => 'utf8'

Spending hours trying to figure out why this works locally but throwing error on Heroku.

I even tried removing the :style setting, but still did not work.

TIA

EDIT

 Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/MidPen20130413-2-1mzetus.mov[0]'

Upvotes: 0

Views: 1185

Answers (1)

pratski
pratski

Reputation: 1488

Well, here is the answer in case any other newbies like us come across the same problem. The issue is with the geometry method that is being used for image cropping. The way it is suggested in railscasts assumes the file is in a local system and that needs to be changed.

OLD METHOD:

def avatar_geometry(style = :original)
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file(avatar.path(style))
end

NEW METHOD

def avatar_geometry(style = :original)
@geometry ||= {}
avatar_path = (avatar.options[:storage] == :s3) ? avatar.url(style) : avatar.path(style)
@geometry[style] ||= Paperclip::Geometry.from_file(avatar_path)
end

Upvotes: 2

Related Questions