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

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)

Related

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

Unable to upload paperclip image in production (AWS)

I seem to have an issue with my paperclip uploads in production. I have deployed with Capistrano to AWS. Here is the error I receive when attempting to upload an image for a user.
Started GET "/" for 127.0.0.1 at 2013-10-02 19:40:48 +0000
Processing by PagesController#home as */*
Rendered pages/home.html.erb within layouts/application (1.1ms)
Completed 200 OK in 6ms (Views: 6.0ms | ActiveRecord: 0.0ms | Solr: 0.0ms)
Started PUT "/users/19" for 98.198.30.70 at 2013-10-02 19:41:09 +0000
Processing by UsersController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0cCRXGjztCv0vs3sxdEcv98aEKTzGcNOXumh6hYPVMU=", "user"=>{"username"=>"chicken", "email"=>"cc#cc.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "avatar"=>#<ActionDispatch::Http::UploadedFile:0x00000006f95f00 #original_filename="download.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"download.jpg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:/tmp/RackMultipart20131002-766-swwl63>>}, "commit"=>"Update Profile", "id"=>"19"}
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: convert '/tmp/download20131002-766-1bap7m5.jpg[0]' -auto-orient -resize "150x150>" '/tmp/download20131002-766-1bap7m520131002-766-12kdsu8'
Command :: file -b --mime '/tmp/download20131002-766-1bap7m520131002-766-12kdsu8'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: convert '/tmp/download20131002-766-1bap7m5.jpg[0]' -auto-orient -resize "300x300>" '/tmp/download20131002-766-1bap7m520131002-766-d8rgc4'
Command :: file -b --mime '/tmp/download20131002-766-1bap7m520131002-766-d8rgc4'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: convert '/tmp/download20131002-766-1bap7m5.jpg[0]' -auto-orient -resize "100x100>" '/tmp/download20131002-766-1bap7m520131002-766-138s58z'
Command :: file -b --mime '/tmp/download20131002-766-1bap7m520131002-766-138s58z'
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: identify -format %m '/tmp/download20131002-766-1bap7m5.jpg[0]'
Command :: convert '/tmp/download20131002-766-1bap7m5.jpg[0]' -auto-orient -resize "50x50>" '/tmp/download20131002-766-1bap7m520131002-766-wyvzz0'
Command :: file -b --mime '/tmp/download20131002-766-1bap7m520131002-766-wyvzz0'
Completed 500 Internal Server Error in 3695ms
Errno::EEXIST (File exists - /home/app/xxx.com/current/public/system):
app/controllers/users_controller.rb:94:in `update'
This is the image link generated by the view:
<img alt="10-m" src="/system/styles/dimages/000/000/519/original/10-m.jpg?1379454321">
However, when I try to browse to this directory in my app I cannot. Perhaps it's a permissions problem? The folder name for system appears in red
app#mothership:~/xxx.com/current/public$ ls
403.html 404.html 422.html 500.html assets favicon.ico robots.txt system
app#mothership:~/xxx.com/current/public$ cd system
-bash: cd: system: No such file or directory
Paperclip is trying to create the /home/app/xxx.com/current/public/system directory, but it's already there. This is likely due to an invalid symlink in your Capistrano deployment.
Check the file and take a look using ls -l and see if it's a symlink pointing the right location. If not, update the symlink by creating the target or changing the location.

ERROR Errno::EINVAL: Invalid argument - <STDOUT> while uploading image with paperclip

I'm using Paperclip with ActiveAdmin to upload pictures in Articles.
But I have a problem, when I'm editing an existing article, the first time after Webrcik started, it functions very well. But systematically, the second time I try to edit an article (whatever the one) Windows tells me that "file.exe" stopped to function, and " Internal Server Error Invalid argument - STDOUT " appears in the browser.
So, I restart webrick, and upload works only one time etc...
Here's the log :
Started PUT "/admin/articles/1" for 127.0.0.1 at 2012-10-24 18:11:45 +0200
Processing by Admin::ArticlesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"VaB3lx3UZaOjUA6Yh+h8jG7ZExSQZDiyZUw6GYJQPbY=", "article"=>{"title"=>"ee", "desc"=>"ee", "content"=>"eeee", "photo"=>#<ActionDispatch::Http::UploadedFile:0x3cce7f0 #original_filename="Desert.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"article[photo]\"; filename=\"Desert.jpg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:C:/Users/Greg/AppData/Local/Temp/RackMultipart20121024-6620-oorxwu>>}, "commit"=>"Update Article", "id"=>"1"}
[1m[35mAdminUser Load (0.0ms)[0m SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = 2 LIMIT 1
[1m[36mArticle Load (1.0ms)[0m [1mSELECT `articles`.* FROM `articles` WHERE `articles`.`id` = ? LIMIT 1[0m [["id", "1"]]
Command :: identify -format %wx%h "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: convert "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]" -auto-orient -resize "510x" -crop "510x350+0+16" +repage "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl20121024-6620-mvfl3a"
Command :: file -b --mime "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl20121024-6620-mvfl3a"
[paperclip] Error while determining content type: Command 'file -b --mime :file' returned 255. Expected 0
Command :: identify -format %wx%h "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Command :: identify -format %m "C:/Users/Greg/AppData/Local/Temp/Desert20121024-6620-16n1ehl.jpg[0]"
Completed 500 Internal Server Error in 22073ms
Errno::EINVAL (Invalid argument - ruby_setenv):
I've been searching for a solution...but I did not find one.
Does someone have an idea of the source of the problem ?
The 'file' program isn't a part of Windows, which suggests you installed it (or something that includes it) to get this far - any idea what that was? Gnu provides a Windows version of 'file' as part of GnuWin32.
Learning more about your copy of that program will probably be the first step to fixing your problem. (Hope this helps.)

Paperclip is failing on certain images but continuing to assign the image to a model

my app integrates with FB. When the user has no image, FB returns:
https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yp/r/yDnr5YfbJCH.gif
While that looks like a normal gif, it breaks paperclip:
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "x50" -crop "50x50+14+0" +repage '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1r9c5af-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "300x300>" '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1cjw8np-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "100x100>" '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-1n3nk3x-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
[paperclip] identify -format %wx%h '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' 2>/dev/null
[paperclip] convert '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-0.gif[0]' -resize "x25" -crop "25x25+7+0" +repage '/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20110517-560-1y0qj3p-020110517-560-rhm4uk-0' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::PaperclipError: There was an error processing the thumbnail for stream20110517-560-1y0qj3p-0>
Even with the error, paperclip still saves the image to the model.
Questions:
Why is it breaking?
How can I tell paperclip that if there is a processing error, abort the image, not the entire process as I'm also saving names etc, but at least stop the image from saving a dead file that ends up 404ing.
Thanks
It looks like it is actually a corrupt image. Downloading it and running identify -format %wx%h yDnr5YfbJCH.gif throws the error:
identify: corrupt image `yDnr5YfbJCH.gif' # error/gif.c/PingGIFImage/958.
200x126
So you can blame Facebook for that one.
Rob on Rails has a good example on how to validate that an upload is a valid image. That should make things work nicely for your end users.

An error was received while processing

How can I find out more about that error?
This is what's shown in the log:
Processing TrendsController#update (for 127.0.0.1 at 2011-01-04 17:24:18) [PUT] Parameters: {"commit"=>"Update", "authenticity_token"=>"WZpPerl3dV+edWXhxLiBlNfv3KTFb0fNLVkhF3ZMNXA=", "id"=>"1", "trend"=>{"title"=>"bluiz", "description"=>"uzgz", "image"=>#}}
[paperclip] identify -format %wx%h "C:/Windows/Temp/stream20110104-3660-1j1ap8i-0.jpg[0]" 2>NUL
[paperclip] convert "C:/Windows/Temp/stream20110104-3660-1j1ap8i-0.jpg[0]" -resize "100x140>" "C:/Windows/Temp/stream20110104-3660-1j1ap8i-020110104-3660-rmkivh-0" 2>NUL
[paperclip] An error was received while processing: #
I had to put the PATH-entries for ImageMagick and FFMPEG before system32 in the environment-variables, because it tried to use Windows' own convert-command.

Resources