When I try to upload a photo in Ruby on Rails using Paperclip on my local machine it works perfectly.
When I try to upload a photo in Ruby on Rails using Paperclip on our Linux (CentOS 5.2) server with Apache and Phusion Passenger, I get:
2 errors prohibited this user from being saved
There were problems with the following fields:
- Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command.
- Avatar /tmp/stream20091026-21120-1qdbnul-0 is not recognized by the 'identify' command.
I tried adding:
Paperclip.options[:command_path] = "/usr/local/bin"
to production.rb but it didn't make a difference.
In the log files I get the following errors:
Parameters: {"commit"=>"Upload",
"action"=>"update", "_method"=>"put",
"authenticity_token"=>"419410afc22737cd2f6b6096a95327db76a48ba9",
"controller"=>"users",
"user"=>{"avatar"=>#}}
[paperclip] Saving attachments.
[paperclip] An error was received
while processing:
/tmp/stream20091026-20752-1g568yk-0 is
not recognized by the 'identify'
command.
Identify is a command-line utility inside the ImageMagick package.
From its homepage:
The identify program describes the
format and characteristics of one or
more image files. It also reports if
an image is incomplete or corrupt. The
information returned includes the
image number, the file name, the width
and height of the image, whether the
image is colormapped or not, the
number of colors in the image, the
number of bytes in the image, the
format of the image (JPEG, PNM, etc.),
and finally the number of seconds it
took to read and process the image.
Many more attributes are available
with the verbose option.
First, copy the image on the server and run the identify command on it. You should receive something like:
identify ~/capture.jpg
capture.jpg JPEG 1216x244 1216x244+0+0 8-bit DirectClass 97.7kb
If you receive an error, try upgrading the ImageMagick package on your server. You may find an updated binary release here:
http://www.imagemagick.org/script/binary-releases.php
in my case with same error, reinstalling imagemagic helped out (ubuntu 12.10)
Related
I got an issue when I tried to upload an image using the paperclip gem.
It is working fine on my ubuntu system but not on windows 10.
Rails version = 5.1.2 Ruby version = 2.2.6p396 paperclip = 5.2.1
[paperclip] Trying to link C:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20180310-5860-1yxm99j.png to C
:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20180310-5860-1mjjyje.png
[paperclip] Link failed with File exists # sys_fail2 - C:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20
180310-5860-1mjjyje.png; copying link C:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20180310-5860-1yxm9
9j.png to C:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20180310-5860-1mjjyje.png
Command :: file -b --mime "C:/Users/.../Temp/c935d187f0b998ef720390f85014ed1e20180310-5860-1mjjyje.png"
[paperclip] Content Type Spoof: Filename Dog.png (image/png from Headers, ["image/png"] from Extension), content type discovered from file command: . See documentation to allow this combination.
Thanks in advance.
As you can see here:
[paperclip] Content Type Spoof: Filename Dog.png (image/png from Headers, ["image/png"] from Extension), content type discovered from file command: . See documentation to allow this combination.
Paperclip (or more precisely file -b --mime command used to identify Content-Type) silently fails leaving you with empty string as a result.
It's working fine on Ubuntu because file program is included in your distribution (you can verify that by using commands like man file or which file). If you run sudo apt remove file on Ubuntu and then try to upload file it will result in error message same as above.
If you want to use Paperclip on Windows, according to this section, you should install file manually and add path to your environment variable:
Download & install file from this URL
Go to GnuWin32 directory and run file.exe to test it works.
Add file.exe path to your PATH variable or add Paperclip.options[:command_path] = 'C:\Program Files (x86)\GnuWin32\bin to your config/environments
I have migrated one Application from Alfresco 4.2 version to Alfresco 5.2 version.
But after up-gradation Image preview is not displaying for any file and Transformation is not working.
Console Logs:-----
2018-02-02 08:58:46,022 INFO [repo.jscript.ScriptNode] [http-apr-8080-exec-25] Unable to create thumbnail 'doclib' for image/tiff as no transformer is currently available.
2018-02-02 08:59:10,076 WARN [jcms.transform.TesseractOCRTransformer] [http-apr-8080-exec-45] Command options did not appear to contain ImageMagick setting for monochrome, cannot invoke Tesseract.
Can anyone please help with this, or any work around to solve this issue.
your valuable reply will be really appreciated.
For more details about issue, please find attached screen-shot.
In the Alfresco Community 5.2 on Windows the ImageMagick install is borked. I found a workaround:
Install ImageMagick from the developer site
https://www.imagemagick.org/script/download.php
Edit the alfresco-global.properties found in C:\alfresco-community\tomcat\shared\classes
Change the img.root value to point to your fresh installation, like this:
img.root=C:\\PROGRA~1\\ImageMagick-7.0.7-Q16
Restart the alfresco server
NOTE: You will see this in the logs before:
err: convert.exe: RegistryKeyLookupFailed `CoderModulesPath' # error/module.c/GetMagickModulePath/670.
convert.exe: no decode delegate for this image format `GIF' # error/constitute.c/ReadImage/509.
Afterwards that error will not be present in the logs.
There's a setenv.bat file that sets up some Imagemagick related environment variables. I suspect they're missing from the build that you have, either by yours or Alfresco's mistake.
After you installed Imagemagick separately, that installation simply took care of these variables.
They go something like this:
MAGICK_HOME="/srv/alfresco-3.4.a/common"
MAGICK_CONFIGURE_PATH="/srv/alfresco-3.4.a/common/lib/ImageMagick-6.5.1/config:/srv/alfresco-3.4.a/common/share/ImageMagick-6.5.1/config"
MAGICK_CODER_MODULE_PATH="/srv/alfresco-3.4.a/common/lib/ImageMagick-6.5.1/modules-Q16/coders"
I try to upload a product image to my Spree app, but i get this error
5errors prohibited this record from being saved:
Attachment Paperclip returned errors for file 'index.jpg' - check ImageMagick installation or image source file.
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Attachment Paperclip::Errors::NotIdentifiedByImageMagickError
Should i install a gem, relocate my src image? Whats the problem here
You should to install ImageMagick. Follow these steps for install on Windows:
Download ImageMagick (you need to choose static version for your 32/64 bit OS)
Checked Add application directory to your system path and install
Reopen your command prompt to reload your PATH variables
Run convert -v to check the install worked
Okay so the problem is pretty complicated and after trying to solve it for about 3 hours i finally got it.
First, you have to remove the convert.exe from your System32 files.
We do this, because the Spree app relies on legacy code and when it
tries to upload the image the default convert.exe starts, we don't
want that.
Second you download and install the dynamic installation from the imagemagick site and you have to be sure to check the legacy support so the convert command gets supported.
I dont know if you have to, but i installed the paperclip gem. You may have to do that for it to work.
The whole reason this bug happens, is because Windows. So if you are new to this party, dual boot your station or swap to Ubuntu/Mac whatever. Seriously though, when the app tries to upload it uses the convert command, but convert is already a default Windows command so you can't upload the picture properly. So we disable the command and then we replace it with our imagemagick installation. That's it.Also good luck trying to delete the convert.exe from system32, its a weird process, but you can solve it with some google-fu.
Thanks to Michael for pointing me to right way.
I have problem with rmagick in Rails 3.
Everything seems to be installed, but I get the following error:
Failed to manipulate with rmagick, maybe it is not an image? Original
Error: unable to open image
`kar/public/uploads/tmp/20110825-1348-30304-9150/thumb_1314198312_by_jannnu11_500.jpg':
# error/blob.c/OpenBlob/2588
File exists. Have good chmod.
This code works on another server.
Any ideas?
In some cases the installation of ImageMagick may have missed some of the file formats required for the image manipulation you are trying to do on that machine.
Try to run identify -list format and see what you are missing from there.
If it turns out that you are just missing the file format, try to uninstall/reinstall and you should be good to go.
I've been searching on how to solve this issue but could not find any real and working solution.
User model:
validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/gif']
Unnecessary error shows up when invalid file type is uploaded:
Avatar /tmp/sample,23283,0.txt is not recognized by the 'identify' command.
Server details:
Ubuntu and Debian
which identify
results to
/usr/bin/identify
Specifying command path does not solve the issue:
Paperclip.options[:command_path] = "/usr/bin"
Any ideas?
I looked at geometry.rb file and there seems to be something wrong with it.
def self.from_file file
file = file.path if file.respond_to? "path"
geometry = begin
Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
rescue PaperclipCommandLineError
""
end
parse(geometry) ||
raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command."))
end
Let me know if anyone has solved the same issue and how. Many thanks.
I've had the same problem - the Paperclip code is not at fault.
In my setup I'm on MacOSX with a binary download of ImageMagick in /usr/local/ImageMagick-6.6.1/bin and I'm running Rails under Apache/Passenger. I've got Paperclip installed as a plugin.
There are 3 steps needed to get this working:
1: Make sure you have ImageMagick working at the UNIX command line level. This involves adding it to your path and exporting these environment variables (pointing to your ImageMagick installation, of course)
MAGICK_HOME=/usr/local/ImageMagick-6.6.1
DYLD_LIBRARY_PATH=/usr/local/ImageMagick-6.6.1/lib
Check that identify works with your images at the command line level.
2: Tell Paperclip where to find the ImageMagick executables
In config/environment.rb add this at the bottom of the file
Paperclip.options[:command_path] = "/usr/local/ImageMagick-6.6.1/bin"
At this point, after restarting Passenger, you would see that 'identify' is run from within Paperclip but is not able to identify the file... the final step is...
3: Identify needs those two exported environment variables - and Apache/Passenger (or other web servers probably) does not pass those through by default!
In your passenger vhost file add these lines:
SetEnv MAGICK_HOME /usr/local/ImageMagick-6.6.1
SetEnv DYLD_LIBRARY_PATH /usr/local/ImageMagick-6.6.1/lib
Restart apache/passenger and it should work
Good Luck!
You should have imagemagick installed which provides the identify command, and its path has to be in the $PATH variable of the user rails is running as.
It is used by paperclip for the scale and image manipulation options, but it is not documented as dependency because you "can" use paperclip without it if you accept the images as they come.
I hope it helps.
http://github.com/thoughtbot/paperclip/issues/issue/167