I've got a problem with ImageMagick and Paperclip.
I'm using on localhost rails3, ruby1.9.2, imagemagick 6.5.8 and paperclip as gem in version 2.3.8.
On production (server) I have rails3, roby1.9.2, imagemagick 6.6.7-4 and the same paperclip as above.
When uploading photos on localhost everything is fine.
But on server my problem appear. It gets error:
[paperclip] identify -format %wx%h
'/tmp/stream20110204-15633-3wdd5s.jpg[0]'
2>/dev/null
[paperclip] An error was received
while processing:
Paperclip::NotIdentifiedByImageMagickError:
/tmp/stream20110204-15633-3wdd5s.jpg
is not recognized by the 'identify'
command.
(the last paragraph is in brackets but I don't know how to avoid hiding it).
Anyone know what's going on?
edit:
All the time I search for some solve and seems that it is problem with ImageMagick. I uploaded some .jpg file on server and try run command "identify file.jpg" and... there is an error:
identify: no decode delegate for this image format `file.jpg' # error/constitute.c/ReadImage/532.
hmm...
Possibly Paperclip doesn't know where to find the ImageMagick binaries. Have you tried setting up an initializer for Paperclip in config/initializers/paperclip.rb ?
Set:
Paperclip.options[:image_magick_path] = "/usr/bin"
On your system you might need /usr/local/bin, or something else entirely. You can find out where the 'identify' binary and other ImageMagick binaries are located by typing:
which identify
If the answer is /usr/bin/identify, then you know to set image_magick_path to /usr/bin
If adding Paperclip.options[:command_path] = "/usr/local/bin/" doesn't work try installing ImageMagick with common delegates:
mkdir /sources cd /sources
wget
ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd ImageMagick-6.6.7-8
Here comes the part makes difference
./configure --disable-static
--with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8
make
sudo make install
Related
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.
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
Following the Railscast episode on CarrierWave:
I installed ImageMagick on Mountain Lion via homebrew, exported the following path:
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
Symlinked the following:
ln -s /usr/local/include/ImageMagick/wand /usr/local/include/wand
ln -s /usr/local/include/ImageMagick/magick /usr/local/include/magick
And installed rmagick via bundler.
In my uploader I have the following:
include CarrierWave::RMagick
version :thumb do
process :resize_to_limit => [85, 85]
end
Which creates thumbnails just fine, but not for png files. I've tried a handful of png images and it always fails with this error:
Failed to manipulate with rmagick, maybe it is not an image? Original Error: no decode delegate for this image format `<path>/public/uploads/tmp/20121022-2133-9885-3333/thumb_cat_vs_internet.png' # error/constitute.c/ReadImage/544
jpeg images work just fine.
EDIT
identify -list format | grep -i png returns nothing, indicating the png decode delegate is probably missing. Now what?
After determining the PNG delegate is not installed (using identify -list format), you should try uninstall/reinstalling ImageMagick as something was likely missed by the installer.
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.
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