Ubuntu Rails 4 Paperclip::Errors::NotIdentifiedByImageMagickError - ruby-on-rails

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)

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.

Anything new for this issue?
I got the same problem and open a new issue on github:
https://github.com/thoughtbot/cocaine/issues/84

Related

Solidus - cannot upload or view images (ImageMagick is installed)

I'm just starting with Solidus, though I do know my way around Rails. I've created a Solidus project on my Mac, and I installed all the required gems as well as ImageMagick through Homebrew. Both identify and magick work as terminal commands as my /usr/local/bin directory is in my PATH. I've also specified the path to identify in the application.rb file (I'm guessing it's supposed to go in side the Application class). However, none of the images show up in Solidus, and when I try and manually add an image, I get the following error (it's related to paperclip). Any help here would be - Google has not been my friend this time. The error message is shown below:
[paperclip] Trying to link /tmp/RackMultipart20200622-9041-8gndhx.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-62aumc.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-62aumc.jpg'
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: PATH=/usr/local/bin/identify:$PATH; identify -format '%wx%h,%[exif:orientation]' '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1dlkgdw.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1dlkgdw.jpg'
[paperclip] Trying to link /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-1t35lnu.jpg to /tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-16yjulo.jpg
Command :: PATH=/usr/local/bin/identify:$PATH; file -b --mime '/tmp/cdcf58ad03be2998ea64da8e6cd3e43c20200622-9041-16yjulo.jpg'
Rendering /Library/Ruby/Gems/2.6.0/gems/solidus_backend-2.10.1/app/views/spree/admin/images/create.js.erb
Rendered /Library/Ruby/Gems/2.6.0/gems/solidus_backend-2.10.1/app/views/spree/admin/images/create.js.erb (Duration: 3.4ms | Allocations: 874)
Completed 200 OK in 836ms (Views: 20.7ms | ActiveRecord: 7.6ms | Allocations: 29100)

Paperclip::Errors::NotIdentifiedByImageMagickError - Rails app + Swift 2

I am trying to upload a photo from a Swift 2 application, and I am getting Bad Request.
I am using:
Amazon EC2
Ruby on Rails
Paperclip
I am executing this code:
Swift
func convertImageToBase64(image: UIImage) -> String {
let imageData = UIImagePNGRepresentation(image)
let base64Encoded = imageData!.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
return base64Encoded
}
and then I send the info through a parameter:
let image_str = self.global.convertImageToBase64(self.global.compressForUpload(self.newMediaImage.image!, withHeightLimit:750, andWidthLimit:750))
parameters["spot[image]"] = "data:image/png;base64,\(image_str)"
notice that my headers are:
headers["Accept"] = "application/json"
headers["Content-Type"] = "multipart/form-data"
headers["Access-Control-Request-Method"] = "POST"
headers["Access-Control-Request-Headers"] = "X-Requested-With"
And I get this message error:
I, [2016-01-07T10:11:41.148123 #4490] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/8d777f385d3dfec8815d20f7496026dc20160107-4490-m5y4d3[0]' 2>/dev/null
I, [2016-01-07T10:11:41.152860 #4490] INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I, [2016-01-07T10:11:41.153061 #4490] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/8d777f385d3dfec8815d20f7496026dc20160107-4490-m5y4d3[0]' 2>/dev/null
I, [2016-01-07T10:11:41.157503 #4490] INFO -- : [paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
I, [2016-01-07T10:11:41.544868 #4490] INFO -- : [AWS S3 400 0.378927 0 retries] head_object(:bucket_name=>"api",:key=>"spots/images//original/data.") AWS::S3::Errors::BadRequest AWS::S3::Errors::BadRequest
I, [2016-01-07T10:11:41.917895 #4490] INFO -- : [AWS S3 400 0.372396 0 retries] head_object(:bucket_name=>"api",:key=>"spots/images//medium/data.") AWS::S3::Errors::BadRequest AWS::S3::Errors::BadRequest
I, [2016-01-07T10:11:42.293064 #4490] INFO -- : [AWS S3 400 0.374527 0 retries] head_object(:bucket_name=>"api",:key=>"spots/images//thumb/data.") AWS::S3::Errors::BadRequest AWS::S3::Errors::BadRequest
A piece of the image that my rails app receive would be:
lN c32Ov1f9nesG/5nVgRpMz wHT1CrwVQ3dM x3tff cnU xpMdWV9MpX1m5Vi\r\n/VvXv3VdB55EHajBVFfUJ1FRayjVfWt1HXg daAGUw2mGkx1HajrQF0HHlUdeB5g\r\nqvtUHlWlq998H9Gbb/N/o3m7brDr/85PqAPPA0w/4cHWje8janzr379uXOs68KTq\r\nQA2musI qQpbA78Gfl0Hfv06UIOpBlMNpp9VB56q2 yp3vfP p3rz713G/M0wFT/\r\nEe79w9Zvlb/ W2X9G9e/8a9aB54GmOo3jhpMdR2o60BdB55NHajBVFf2Z1PZf9W3\r\ny/S9ql6Far6u399ev vn e3P8J71sAbTPR/YL9241c/ih/8B6/pUu PqOvDvdaAG\r\nU90Y141xXQfqOlDXgUdVB2ow1RXyUVXI u3x398ev mZ1G6oun4/wTauBtMT/NG \r\nqaGqv2/dUNV1oK4Dj7wO1GB65D9QDaEHVhD17103ynUdePR1oAZTXUkffSWt4VzD\r\nua4Dz6sO1GCqwVSDqa4DdR2o68CjqgM1mOoK agqZP1m/LzejOvfu/69b6oDNZhq\r\nMNVgsg7U0Wt1PajbgkdTB2ow1ZXx0VTGm96c6rL6jbquA8 vDtRgqsFUg6muA3Ud\r\nqOvAo6oDNZiee4WsXViP6g/5IOrA37T XX/871o/8wd75jWYnjuY6u//YH mB4FK\r\n/XvUv0ddB17UYKorQd0Q1HWgrgN1HXhUdaAGU10hH1WFrFXH8 vorn/z jdvrgM1\r\nmGow1WCq60BdB o68KjqQA2mukI qgrZ/OZUb9dv03UdeH51oAZTDaYaTHUdqOtA\r\nXQceVR2owVRXyEdVIeu34 f3dlz/5vVv3lwHajDVYKrBVNeBug7UdeBR1YEaTHWF\r\nfFQVsvnNqd6u36brOvD86kANphpMNZjqOlDXgboOPKo6UIOprpCPqkLWb8fP7 24\r\n/s3r37y5DtRgqsFUg6muA3UdqOvAo6oDNZjqCvmoKmTzm1O9fYe36Xry0LoO/2Lt\r\nWA2mX wHrRvyOzTk9W9eN R1HXjUdaAGU11BH3UFrUFbg7auA8 vDtRgqsFUg lX\r\nrQO1i6 u20 0bn/6/135Eixq4JAOAAAAAElFTkSuQmCC
It's working now. The solution was:
I just changed the version of the aws-sdk gem which was < 2 to
gem 'aws-sdk', '>= 2.0.0' and it worked pretty well.
Besides that, I re-installed imagemagick on amazon ec2 and Rmagick.

Paperclip on Rails 4.0 strange warnings

I'm trying to test my controller which deal with images by paperclip. However, when I ran rspec, there are a lot of strange warnings from paperclip I guess. The warnings are look like this:
I, [2014-08-17T03:20:20.852108 #36314] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' 'spec/assets/images/test_banner.jpg[0]' 2>/dev/null
I, [2014-08-17T03:20:20.866725 #36314] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' 'spec/assets/images/test_banner.jpg[0]' 2>/dev/null
I, [2014-08-17T03:20:20.881726 #36314] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' 'spec/assets/images/test_banner.jpg[0]' 2>/dev/null
Can anyone tell me what are those warnings and how can I fix it?
Environment infos: Rails 4.1.4, latest paperclip, mongoid-paperclip.
Those are not warnings, they are informational statements that paperclip is logging. You can turn paperclip's logging off for testing by adding the following in your config/environments/test.rb:
Your::Application.configure do
...
Paperclip.options[:log] = false
...
end
See Paperclip readme for further details.

Heroku 500 Error, while using Heroku, Rails [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am trying to upload images to S3 using paperclip. It currently works perfectly in development, but when I push it to heroku I get a status 500.
I've looked on current topics and some reasons for this are either the lack of a pg gem and bucket name not configured but I've checked those.
My error log currently says this
2014-06-22T23:13:44.118505+00:00 app[web.1]: I, [2014-06-22T23:13:44.118013 #2] INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "x100" -crop "100x100+99+0" +repage -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-10cae74.jpg'
2014-06-22T23:13:44.040021+00:00 app[web.1]: I, [2014-06-22T23:13:31.758844 #2] INFO -- : Rendered patients/new.html.erb within layouts/application (2.6ms)
2014-06-22T23:13:44.040023+00:00 app[web.1]: I, [2014-06-22T23:13:31.759625 #2] INFO -- : Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
2014-06-22T23:13:44.040024+00:00 app[web.1]: I, [2014-06-22T23:13:44.027440 #2] INFO -- : Started POST "/patients" for 107.19.177.84 at 2014-06-22 23:13:44 +0000
2014-06-22T23:13:44.040026+00:00 app[web.1]: I, [2014-06-22T23:13:44.031624 #2] INFO -- : Processing by PatientsController#create as HTML
2014-06-22T23:13:44.081130+00:00 app[web.1]: I, [2014-06-22T23:13:44.080608 #2] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.040028+00:00 app[web.1]: I, [2014-06-22T23:13:44.031790 #2] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"6LvlNWsTg6qCoILIbt1pjvUX1mvP+WbnHUX4yYVPHdI=", "patient"=>{"name"=>"Yitao Zhang", "number"=>"6503916966", "email"=>"yitaoz#stanford.edu", "appointment"=>"2014-06-16", "avatar"=>#<ActionDispatch::Http::UploadedFile:0x007f7324f6e7f0 #tempfile=#<Tempfile:/tmp/RackMultipart20140622-2-1gopf5s>, #original_filename="images.jpeg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"patient[avatar]\"; filename=\"images.jpeg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"adsafasdf"}, "commit"=>"Submit"}
2014-06-22T23:13:44.184102+00:00 app[web.1]: I, [2014-06-22T23:13:44.183584 #2] INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-10cae74.jpg'
2014-06-22T23:13:44.040030+00:00 app[web.1]: I, [2014-06-22T23:13:44.038575 #2] INFO -- : Command :: file -b --mime-type '/tmp/8f2ed61a3cb4149d8c9abca38721647720140622-2-1c1dac6'
2014-06-22T23:13:44.260870+00:00 app[web.1]: I, [2014-06-22T23:13:44.260288 #2] INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "x480" -crop "480x480+478+0" +repage -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-ye2lmv.jpg'
2014-06-22T23:13:44.470900+00:00 app[web.1]: I, [2014-06-22T23:13:44.470357 #2] INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-ye2lmv.jpg'
2014-06-22T23:13:44.544510+00:00 app[web.1]: I, [2014-06-22T23:13:44.543987 #2] INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "600>" -set colorspace sRGB -strip '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-1rbg2jr.jpg'
2014-06-22T23:13:44.621867+00:00 app[web.1]: I, [2014-06-22T23:13:44.621332 #2] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.590252+00:00 app[web.1]: I, [2014-06-22T23:13:44.589723 #2] INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-1rbg2jr.jpg'
2014-06-22T23:13:44.506015+00:00 app[web.1]: I, [2014-06-22T23:13:44.505469 #2] INFO -- : Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' 2>/dev/null
2014-06-22T23:13:44.662154+00:00 app[web.1]: I, [2014-06-22T23:13:44.661637 #2] INFO -- : Command :: convert '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y3[0]' -auto-orient -resize "1200>" -set colorspace sRGB -strip -sharpen 0x0.5 '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-fpzvpn.jpg'
2014-06-22T23:13:44.743824+00:00 app[web.1]: I, [2014-06-22T23:13:44.743315 #2] INFO -- : Command :: file -b --mime '/tmp/eba6328b7631122493d269f7c5d3781d20140622-2-1f1t7y320140622-2-fpzvpn.jpg'
2014-06-22T23:13:44.836262+00:00 heroku[router]: at=info method=POST path="/patients" host=glacial-scrubland-2600.herokuapp.com request_id=47cf63e3-59f9-4dc0-be18-fc06ae702775 fwd="107.19.177.84" dyno=web.1 connect=1ms service=1078ms status=500 bytes=1543
2014-06-22T23:13:44.790408+00:00 app[web.1]: I, [2014-06-22T23:13:44.789786 #2] INFO -- : Command :: file -b --mime-type '/tmp/47f9c6187d138877e010f0255fe25ac920140622-2-1fmy0hr'
The only hint I have is that status=500.
Would really appreciate any thoughts / help!
ENV Vars
The most pertinent issue will likely be that you've not got your ENV variables set up correctly. These are environment specific - meaning you will have to set them in each "environment" (server) you deploy your app to
A common problem for many is they will deploy to Heroku without setting these ENV vars, consequently preventing the system from accessing the information it needs.
The solution is to use heroku config:set VARIABLE=value in your CMD
--
Production
Your log doesn't have any errors, which isn't very helpful
One other piece of speculation, therefore, would be the idea that you've not set the production environment options in Rails itself:
#config/environments/production.rb
config.paperclip_defaults = {
:storage => :s3,
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
There is another issue you may have, which is how paperclip uses the bucket option. We've found that it requires this setup to work correctly:
#config/environments/production.rb
config.paperclip.defaults = {
storage: :s3,
s3_host_name: 's3-eu-west-1.amazonaws.com',
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
},
bucket: ENV['S3_BUCKET_NAME']
}

Paperclip style not respected

I have a Picture model, which has attached file picture, using Paperclip.
class Picture < ActiveRecord::Base
[...]
has_attached_file :photography, styles: { thumb: '115x', gallery: '560x560' }
[...]
end
File corresponding to thumb style is perfect but file corresponding to gallery style is always 560px width. I want to obtain a file with every sides of 560px maximum.
Eg:
Original size 1000x800px => gallery size 560x468
Original size 800x1000px => gallery size 700x560
Paperclip debug output:
Started POST "/admin/pictures/create" for 127.0.0.1 at 2013-01-29 13:21:26 +0100
Processing by Admin::PicturesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"3mDW4HeWq3SV/KJ8ez09c+/Y1dNcCkqN+8uUUx5SnGk=", "picture"=>{"realization_id"=>"3", "photography"=>#<ActionDispatch::Http::UploadedFile:0x007fe984776c10 #original_filename="IFFTS-37-2.jpeg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"picture[photography]\"; filename=\"IFFTS-37-2.jpeg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/RackMultipart20130129-12408-a9zr3v>>, "name"=>"test", "active"=>"1"}, "_save"=>"Save"}
Command :: identify -format %wx%h '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: identify -format %m '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: identify -format %m '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: convert '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]' -auto-orient -resize "115" '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja20130129-12408-1boh1t1'
Command :: file -b --mime '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja20130129-12408-1boh1t1'
Command :: identify -format %wx%h '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: identify -format %m '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: identify -format %m '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]'
Command :: convert '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja.jpeg[0]' -auto-orient -resize "560x560" '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja20130129-12408-fqtxxs'
Command :: file -b --mime '/var/folders/gh/q_r38fpj4qv5t8ymtq713d_w0000gn/T/IFFTS-37-220130129-12408-ssh5ja20130129-12408-fqtxxs'
If I run the same command in terminal, everything works fine:
convert picture.jpeg -auto-orient -resize 560x560 picture.jpeg
(Same issue on Heroku)
Any ideas ?
Try Following
has_attached_file :photography, styles: { thumb: '115x', gallery: '560x560>' }
I suggest you to stop using paperclip since its heavy and use carrierwave. Its quite light. I was using paperclip initially and then switched to carrierwave. Pretty simple to deploy.

Resources