Photo is not recognized by the 'identify' command [duplicate] - ruby-on-rails

I'm getting the following error in my development.log
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream28514-0 is not recognized by the 'identify' command.>
And i've googled about this error and i found out that many people have solved this by adding this line
Paperclip.options[:command_path] = "/usr/local/bin"
However, i still get the same error even after adding that line! I've tried everything possible!
Any help would be highly appreciated!
Regards,
Punit

The Paperclip.options[:command_path] setting is for the location of your ImageMagick executables (in this case identify). Try running which identify and setting the option to be the directory that is returned. If that command doesn't return anything, make sure that ImageMagick is properly installed.

Here is what worked for me...
I uninstalled the imagemagick that i installed from the official webpage.
I reinstalled it from sudo apt-get install imagemagick
then i did write Paperclip.options[:command_path] = "to/correct/path"
THE PROBLEM HERE WAS...
when i ran "which identify" it appearde that the path was "usr/local/bin/identify"
it means that we I was supposed to put as a path "usr/local/bin" as my path.
BUT IT DIDN'T WORKED!
I surprisingly found that i identify was also in the "usr/bin" path. So i changed:
"usr/local/bin" to "usr/bin"
And that was all!

It means that it cannot find ImageMagick's executable identify on the location you specified in Paperclip.options[:command_path] (in your case /usr/local/bin).
This is tipically caused by two reason:
It might be that you actually did not installed ImageMagick.
SOLUTION: install it:
For MAC: sudo port install ImageMagick (which installs the binary release)
For UBUNTU: sudo sudo apt-get install imagemagick
It might be that the location where you installed ImageMagick is not /usr/local/bin but something else.
SOLUTION: find where it is installed, or via the command:
which identify (in case that identify is in the current PATH, as it should be)
or via a raw find through the file system:
find / -name identify
Anyway, the usual location for those file in Ubuntu should be /usr/bin

There are two possible problems:
Image Magick is not installed or broken
Paperclip is not able to find Image Magick
Let's take them one at a time:
1. Check you have Image Magick installed and it is working
Type:
identify
at the command line, it should work. If it isn't found, or fails to work, install Image Magick. Did this fix it? If not, continue:
2. Help Paperclip find Image Magick
Type:
which identify
at the command line to get the path to the identify command. Now, in production.rb, add the following line to the configuration block:
Paperclip.options[:command_path] = "/usr/bin"
Restart your server. That should fix it.

usr/bin worked me (Fedora 14 core)

Try running the identify command in the command line and see if that gives you some error message. I found out that my server was missing some delegate libraries.
identify example.jpg

Related

Installing imagemagick using homebrew -- can't find command

I tried installing imagemagick using homebrew on a Mac. Specifically, I did:
brew install imagemagick
in terminal. There were no error messages. When I go to use imagemagick, e.g. using the command:
magick convert
I don't see the magick command available when I try to tab complete. I'm a bit uncertain how to debug this -- it seems like it should have installed fine?
As part of installing homebrew you need to set your PATH so your shell knows where the executable binaries are installed.
Depending on your homebrew version and macOS hardware and software, you may need:
export PATH=/opt/homebrew/bin:$PATH
or
export PATH=/usr/local/bin:$PATH
You can tell which of the two commands above you need with:
find {/opt/homebrew,/usr/local}/bin -name magick
Then run:
hash -r
and all homebrew commands like magick should work for your current session.
If you want the PATH set correctly for all future sessions you will need to add the export command from above to your login profile. That will depend on your shell, but is probably:
$HOME/.zprofile
or
$HOME/.profile
Note that you should read this answer to understand why you do NOT want to use magick convert.

Ghostscript installed but not found RGhost::Config::GS[:path]='/path/to/my/gs'

I've been trying for a few hours now solve this problem and I looked everywhere for a solution and I did not find one. I'm trying to run a spec test for my project and I have the following error coming up:
RuntimeError:
Ghostscript not found in your system environment (linux-gnu).
Install it and set the variable RGhost::Config::GS[:path] with the executable.
Example: RGhost::Config::GS[:path]='/path/to/my/gs' #unix-style
RGhost::Config::GS[:path]="C:\\gs\\bin\\gswin32c.exe" #windows-style
And I do try to put RGhost::Config::GS[:path]='/usr/local/bin/gs' and it returns:
bash: RGhost::Config::GS[:path]=/usr/local/bin/gs: No such file or directory
but ghostscript is installed, I did everything (make, sudo make install, etc etc) and when I run gs -v it returns:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
When I use the user interface and search for "gs" in the "Files" application, it is found in /home/marcelle/projects/ghostscript-9.26/bin/gs and I also tried:
RGhost::Config::GS[:path]='/home/marcelle/projects/ghostscript-9.26/bin/gs'
and it returns the same error:
bash: RGhost::Config::GS[:path]=/home/marcelle/projects/ghostscript-9.26/bin/gs: No such file or directory
I also tried to delete ghostscript from my notebook with autoremove and purge and installed it again using what I mentioned before (./configure, make, sudo make install), restarted the notebook, the terminal and nothing.
PS: I'm using Ubuntu 20.04.
I managed to figure out a solution. Looking for the code for the Rghost, what I saw in its spec is that the path expected was different than the path the ghostscript really is.
When I run whereis or which on my terminal, it returns:
which gs
/usr/local/bin/gs
So I was trying to point to this path. But seeing the spec test for Rghost which I found on github for Rghost, we can see that it expects /usr/bin/gs:
it 'should detect linux env properly' do
RbConfig::CONFIG.should_receive(:[]).twice.with('host_os').and_return('linux')
File.should_receive(:exists?).with('/usr/bin/gs').and_return(true)
RGhost::Config.config_platform
RGhost::Config::GS[:path].should == '/usr/bin/gs'
end
So it expects /usr/bin and not /usr/local/bin.
Then I just copied to that path and the spec ran with no problems anymore:
sudo cp /usr/local/bin/gs /usr/bin
I've no experience with Ruby at all, but I also got this error when using asciidoctor, which uses rghost for the PDF generation.
The command RGhost::Config::GS[:path]='/path/to/my/gs' mentioned in the error is not a shell command, which is why bash couldn't handle it. However, to me it wasn't immediately clear what to do with this command either. I expected an easy way to set this variable somewhere, but couldn't find it.
What worked for me was searching the rghost.rb file, which is where this variable is set and can be changed. In Windows, it was located in C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\rghost-0.9.7\lib\rghost.rb.
In this file, I added the following line, which solved the problem:
RGhost::Config::GS[:path]="C:\\Program Files\\gs\\gs9.55.0\\bin\\gswin64c.exe"
NB: the mentioned paths can be different for everyone, so make sure to use that paths that are valid for your system.

convert from ImageMagick works on command line but not from localhost

I am able to do use the ImageMagick convert function on the command line with no problems:
/usr/local/magick/bin/convert a.pdf b.png
I then put it in a one-line PHP file named testconvert.php:
system("/usr/local/magick/bin/convert a.pdf b.png", $code);
and it works fine as a command line call from PHP:
php testconvert.php
But, when I run the script from my browser on localhost:
http://localhost/~me/testconvert.php
I get the error:
convert: no images defined `b.png' # error/convert.c/ConvertImageCommand/3253
I found a lot of folks who have encountered similar problems and fixes ranged from using the absolute path for the files (didn't help) to installing ghostscript (didn't help, either). I'm going a bit gaga with this. Would anyone have any thoughts about what I can possibly try?
Thanks!
Change your system() line to:
system("pwd");
and you will see which directory your script is running in.

RefineryCMS image uploading error, ImageMagick CentOS 5.5

I installed RefineryCMS on my server(CentOs 5.5) and everything works fine except uploading images. It will show an error like:
NoMethodError in Refinery::Admin::ImagesController#create
undefined method `downcase' for nil:NilClass
I installed ImageMagick by typing:
sudo yum install ImageMagick
I searched online and it seems ImageMagick installed by yum is too old (Version 6.2.x)
Then I removed it, successfully installed ImageMagick v6.7.7 from source code.
Now when I try to upload an image, refinery shows:
Dragonfly::Shell::CommandFailed in Refinery::Admin::ImagesController#create
Command failed (identify '/tmp/RackMultipart20120628-29239-70xr45') with exit status 127
However, if I run that command "identify '/tmp/RackMultipart20120628-29239-70xr45'" in the command line, it will show the result without any error. It seems that Dragonfly can not pick up my installation of the lastest version of ImageMagick. Could any one tell me how to configure it ? Or should I upgrade my centOS ?(I wish not)
Well, I have struggled with this issue for more than one week.
I also asked this question in Github and finally got the solution there.
see: https://github.com/resolve/refinerycms/issues/1781#issuecomment-6823858
Since this problem is caused by that Dragonfly can not find imagemagick.
You can try add the following code to config/application.rb
initializer 'override-image-magick-paths', :after => 'attach-refinery-images-with- dragonfly' do
app=Dragonfly[:refinery_images]
app.configure_with(:imagemagick)
app.configure do |c|
c.convert_command = "/usr/local/bin/convert" # defaults to "convert"
c.identify_command = "/usr/local/bin/identify" # defaults to "identify"
end
end
Modify the path according to your imagemagick installation.
You can use which command to find the path. e.g. which convert
However, this still doesn't work for me.
And finally, toymachiner62 find a solution which is simple and works perfect.
That is to use symbolic link:
$ cd /usr/bin
$ ln -s /usr/local/bin/convert convert
$ ln -s /usr/local/bin/identify identify
modify the /usr/local/bin/convert paths to you installation as well.
This looks like my /usr/local/bin path is not in my $PATH, but actually it is.
Dragonfly just seems can not find it anyway.

Paperclip Error

I'm getting the following error in my development.log
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream28514-0 is not recognized by the 'identify' command.>
And i've googled about this error and i found out that many people have solved this by adding this line
Paperclip.options[:command_path] = "/usr/local/bin"
However, i still get the same error even after adding that line! I've tried everything possible!
Any help would be highly appreciated!
Regards,
Punit
The Paperclip.options[:command_path] setting is for the location of your ImageMagick executables (in this case identify). Try running which identify and setting the option to be the directory that is returned. If that command doesn't return anything, make sure that ImageMagick is properly installed.
Here is what worked for me...
I uninstalled the imagemagick that i installed from the official webpage.
I reinstalled it from sudo apt-get install imagemagick
then i did write Paperclip.options[:command_path] = "to/correct/path"
THE PROBLEM HERE WAS...
when i ran "which identify" it appearde that the path was "usr/local/bin/identify"
it means that we I was supposed to put as a path "usr/local/bin" as my path.
BUT IT DIDN'T WORKED!
I surprisingly found that i identify was also in the "usr/bin" path. So i changed:
"usr/local/bin" to "usr/bin"
And that was all!
It means that it cannot find ImageMagick's executable identify on the location you specified in Paperclip.options[:command_path] (in your case /usr/local/bin).
This is tipically caused by two reason:
It might be that you actually did not installed ImageMagick.
SOLUTION: install it:
For MAC: sudo port install ImageMagick (which installs the binary release)
For UBUNTU: sudo sudo apt-get install imagemagick
It might be that the location where you installed ImageMagick is not /usr/local/bin but something else.
SOLUTION: find where it is installed, or via the command:
which identify (in case that identify is in the current PATH, as it should be)
or via a raw find through the file system:
find / -name identify
Anyway, the usual location for those file in Ubuntu should be /usr/bin
There are two possible problems:
Image Magick is not installed or broken
Paperclip is not able to find Image Magick
Let's take them one at a time:
1. Check you have Image Magick installed and it is working
Type:
identify
at the command line, it should work. If it isn't found, or fails to work, install Image Magick. Did this fix it? If not, continue:
2. Help Paperclip find Image Magick
Type:
which identify
at the command line to get the path to the identify command. Now, in production.rb, add the following line to the configuration block:
Paperclip.options[:command_path] = "/usr/bin"
Restart your server. That should fix it.
usr/bin worked me (Fedora 14 core)
Try running the identify command in the command line and see if that gives you some error message. I found out that my server was missing some delegate libraries.
identify example.jpg

Resources