rustyHack
rustyHack

Reputation: 63

Ubuntu Rails 4 Paperclip::Errors::NotIdentifiedByImageMagickError

I've seen similar post with this error but none of them fixed my problem. I'm using ImageMagick (6.9.0.8)and Paperclip for uploading images to my Rails 4 app. It is working on my development machine, a Mac, but not on my DigitalOcean account (Ubuntu 14.04, Nginx, Unicorn). When Paperclip tries saving different sizes of the images, ImageMagick give the error:

Paperclip::Errors::NotIdentifiedByImageMagickError

I'm using the Paperclip 4.2.1 and Cocaine .0.5.5 gems. In my Rails model I have:

has_attached_file :photo_image, :styles => { :medium => "330x250#", :small => "150x120#", :thumb => "120x100#" }, 
                            :url => "/system/dadverts/:attachment/:id/:style/:filename",
                            :path => ":rails_root/public/system/dadverts/:attachment/:id/:style/:filename",
                            :default_url => "300250ad.png"

validates_attachment_content_type :photo_image, :content_type => /\Aimage/

In my production environment settings I have:

Processing by AdvertisementsController#create as HTML
I, INFO -- :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"8hHWBxpydUyA1MEucXtnSvvRvHc38LcM1hbb8Is/cd4=", "advertisement"=>{"customer_name"=>"Kayak Venice", "ad_network_name"=>"Recon Outpost", "sitead_location_id"=>"1", "publish_date(1i)"=>"2015", "publish_date(2i)"=>"3", "publish_date(3i)"=>"14", "expiration_date(1i)"=>"2020", "expiration_date(2i)"=>"3", "expiration_date(3i)"=>"14", "keywords_alt_text"=>"", "sort_order"=>"1", "local_ad"=>"0", "zipcode"=>"00000", "photo_image"=>#<ActionDispatch::Http::UploadedFile:0x00000005c93038 @tempfile=#<Tempfile:/tmp/RackMultipart20150314-2186-1jc6u31>, @original_filename="KayakLogoConcept3.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"advertisement[photo_image]\"; filename=\"KayakLogoConcept3.png\"\r\nContent-Type: image/png\r\n">, "render_options"=>"1", "click_thru_url"=>"", "external_media_embed"=>""}, "advertisment"=>{"publish"=>"0"}, "commit"=>"Create Advertisement"}
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH file -b --mime '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-pxyhur.png'
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-o1r33b.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-o1r33b.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-o1r33b.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH file -b --mime '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-91e4eo.png'
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-fwjtt8.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-fwjtt8.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH identify -format '%wx%h,%[exif:orientation]' '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-fwjtt8.png[0]' 2>/dev/null
I,  INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I,  INFO -- : Command :: PATH=/usr/local/bin/:$PATH file -b --mime '/tmp/af961aaf697aaa71682a6e9716d6034520150314-2186-k19vf3.png'
I,  INFO -- :   Rendered advertisements/_form.html.erb (65.2ms)

Upvotes: 0

Views: 1450

Answers (2)

rolele
rolele

Reputation: 843

Anything new for this issue? I got the same problem and open a new issue on github:

https://github.com/thoughtbot/cocaine/issues/84

Upvotes: 0

Maxim
Maxim

Reputation: 9961

This error class has description:

# Will be thrown when ImageMagic cannot determine the uploaded file's
# metadata, usually this would mean the file is not an image.

This is mean that you are trying to process not image file. Seems like it can be related to incorrect extension of temporary file. Look at this file extension:

af961aaf697aaa71682a6e9716d6034520150314-2186-o1r33b.png[0]

As you can see it has [0] at the end. So, try to investigate why this extension is appear. Seems like you are using custom processor base on Cocaine. I think problem can be related to it.

Upvotes: 1

Related Questions