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.)
Related
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)
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!
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.
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.
When using CKEditor + Paperclip on rails 3 I get this error message when uploading an image via the wysiwyg editor:
Started POST "/ckeditor/pictures?CKEditor=question%5Banswers_attributes%5D%5B0%5D_body_editor&CKEditorFuncNum=2&langCode=en" for 127.0.0.1 at 2011-06-11 18:11:58 -0500
Processing by Ckeditor::PicturesController#create as HTML
Parameters: {"upload"=>#>, "CKEditor"=>"question[answers_attributes][0]_body_editor", "CKEditorFuncNum"=>"2", "langCode"=>"en"}
[paperclip] identify -format %wx%h '/var/folders/11/114evplqEWuTFgn6byOUQE+++TI/-Tmp-/stream20110611-1900-1hpvz8i.gif[0]' 2>/dev/null
[paperclip] An error was received while processing: #
[paperclip] identify -format %wx%h '/var/folders/11/114evplqEWuTFgn6byOUQE+++TI/-Tmp-/stream20110611-1900-1hpvz8i.gif[0]' 2>/dev/null
[paperclip] An error was received while processing: #
User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY last_name ASC LIMIT 1
Rendered text template (0.0ms)
Completed 200 OK in 214ms (Views: 0.9ms | ActiveRecord: 1.2ms)
Is this a error with paperclip or?
Is identify installed (image magick) and in the PATH for your application?
(posting so question doesn't appear in unanswered list)
Edit: Forgot to mention this might need to go in environments/*.rb:
Paperclip.options[:command_path] = "/usr/local/bin" # or path to wherever identify is located.