Paperclip on Rails 4.0 strange warnings - ruby-on-rails

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.

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)

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)
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

Rails 3 Paperclip issues

i'm using Rails 3 and paperclip to upload some pictures.
However, each time i want to upload some pictures, if i perform a
new_picture.valid?
it returns me false.
I installed imageMagick and set the path in my windows environment variables.
But here is a problem, i'm using thin server, and in the console it return me a message when i try to upload the pictures:
I'm French, it returns me
"Paramètre non valide - /Users"
In english : "Invalid Parameter - /Users"
Here is what my image parameter contain:
"image"=>[#<ActionDispatch::Http::UploadedFile:0x5770710 #original_filename="Desert.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"service[service_pictures][image][]\"; filename=\"Desert.jpg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:C:/Users/XXX/AppData/Local/Temp/RackMultipart20140210-2252-3r9p4g>>]
I think that the problem is located in where the tempfile is placed : "C:/Users/...
Because i'm french, on my computer C:/Users is named C:/Utilisateurs
Do you think that due to this ImageMagick would not be able to find the tempfile and so unable to perform its actions on it?
Here are my logs
Command :: identify -format '%wx%h,%[exif:orientation]' "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw.jpg[0]"
Command :: identify -format %m "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw.jpg[0]"
Command :: identify -format %m "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw.jpg[0]"
Command :: identify -format %m "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw.jpg[0]"
Command :: convert "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw.jpg[0]" -auto-orient -resize "x144" -crop "145x144+23+0" +repage "C:/Users/Fred-Dev/AppData/Local/Temp/Desert20140210-2252-jpumkw20140210-2252-1fia7d"
[paperclip] An error was received while processing:
Paperclip::Error: There was an error processing the thumbnail for Desert20140210-2252-jpumkw>
Have you any idea on how i could solve my problem?
Thanks in advance for the help
best regards
RESOLVED
In fact in the windows environment variables, you have to place the path to imageMagick in FIRST, before the windows one.
It's now working properly for me!

Why image upload could be failing just in production?

I saw Why is Paperclip failing silently in production + development? and Paperclip images failing to save in production rails.
In development my form uploads images correctly.
In console I see log for ImageMagick commands:
Command :: identify -format %wx%h '/tmp/Screen Shot 2013-05-20 at 1.07.24 AM20130526-23150-hy913i.png[0]'
Command :: identify -format %m '/tmp/Screen Shot 2013-05-20 at 1.07.24 AM20130526-23150-hy913i.png[0]'
Command :: identify -format %m '/tmp/Screen Shot 2013-05-20 at 1.07.24 AM20130526-23150-hy913i.png[0]'
Command :: convert '/tmp/Screen Shot 2013-05-20 at 1.07.24 AM20130526-23150-hy913i.png[0]' -auto-orient -resize "10
.... more lines like these
In production I have:
Paperclip.options[:command_path] = "/usr/bin/"
And which convert outputs /usr/bin/convert
Update
I am using EC2.

Paperclip attachments don't save under unicorn

I'm running a rails 3.0.12 application with Paperclip 2.6 under Ubuntu + Nginx + Unicorn setup. In production, my image attachments seemed to upload fine, but upon checking the image path, I couldn't find the files, so I started messing around.
Ultimately, I found that if I ran the built-in rails dev server (rails s), the attachments would upload just fine to the correct path. But under unicorn, while the attachments do get uploaded, a) they get saved to /tmp/randompath on the server, and all the resized images for each of the styles also get saved with a bunch of random characters in the filename, including the upload date and time.
Not sure what is going on here. Here is the rails log when run under the rails dev server (in the production environment):
Command :: identify -format %wx%h '/tmp/stream20120626-4215-axmd16.png[0]'
Command :: convert '/tmp/stream20120626-4215-axmd16.png[0]' -resize "x100" -crop "100x100+185+0" +repage '/tmp/stream20120626-4215-axmd1620120626-4215-1droo3w'
Command :: identify -format %wx%h '/tmp/stream20120626-4215-axmd16.png[0]'
Command :: convert '/tmp/stream20120626-4215-axmd16.png[0]' -resize "280x" -crop "280x55+0+2" +repage '/tmp/stream20120626-4215-axmd1620120626-4215-fzxeg1'
...
...
UPDATE `organizations` SET `logo_file_name` = 'logo.png', `logo_file_size` = 5682, `logo_updated_at` = '2012-06-26 19:48:47', `updated_at` = '2012-06-26 19:48:48' WHERE `organizations`.`id` = 1
[paperclip] Saving attachments.
[paperclip] saving /home/deploy/apps/xxx_staging/releases/20120626193037/public/system/organization/1/original/logo.png
[paperclip] saving /home/deploy/apps/xxx_staging/releases/20120626193037/public/system/organization/1/thumb/logo.png
And under unicorn, the log shows:
Command :: identify -format %wx%h '/tmp/1docway_logo20120626-11230-1wodane.jpg[0]'
Command :: convert '/tmp/1docway_logo20120626-11230-1wodane.jpg[0]' -resize "x100" -crop "100x100+135+0" +repage '/tmp/1docway_logo20120626-11230-1wodane20120626-11230-1y0j5hm'
Command :: identify -format %wx%h '/tmp/1docway_logo20120626-11230-1wodane.jpg[0]'
Command :: convert '/tmp/1docway_logo20120626-11230-1wodane.jpg[0]' -resize "280x" -crop "280x55+0+10" +repage '/tmp/1docway_logo20120626-11230-1wodane20120626-11230-1bwx4go'
[paperclip] Saving attachments.
[paperclip] deleting /home/deploy/apps/xxx_staging/releases/20120620214744/public/organization/1/original/1docway_logo.png
[paperclip] deleting /home/deploy/apps/xxxx_staging/releases/20120620214744/public/organization/1/thumb/1docway_logo.png
As you can see, the second set of logs has no UPDATE command being run, or files being saved to the /home/deploy/apps/xxx_staging/releases/xxx/public/system/ folder

Resources