Error in paper clip plugin in rails - ruby-on-rails

Image Paperclip::CommandNotFoundError
I am getting this error.
Installed Image magick, rmagic both specified path in developement.rb
Paperclip.options[:command_path] = "/opt/local/bin"
Using Snow Leapord

check logs to see which command failed. probably it looks for other complementary executables not present in your custom path. for example paperclip also needs 'identify' command, provided with imagemagick. so be sure to have all executables you need.

Try putting the Paperclip.options[:command_path] in a file in config/intializers

Removing this line worked for me.
Paperclip.options[:command_path] = "/opt/local/bin"

make sure you have RMagick installed

Related

Rails 2 + Paperclip + ImageMagick in Linux is not working?

I set up a app in windows using paperclip and imagemagick and it works fine.
Now, I had to migrate this APP to linux.
I already have paperclip's gem and imagemagick but I can't make it work.
I keep getting this message when saving the image:
sh: identify: command not found
Why? Am I missing something?
Thank you!
ps: I'm able to run the "identify" command from my app's directory.
Within your config/environments/development.rb file (or production if necessary) you can add Paperclips command_path option:
Paperclip.options[:command_path] = '/opt/local/bin'
You will want to replace /opt/local/bin with the directory path returned typing in your command line:
$ which identify

Rails 3 and rmagick

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.

paperclip error

i am trying paperclip for the first time and followed this tutorial
all is well until i use styles. this is the code
has_attached_file :photo, :url => "/uploads/products/:id/:style/:basename.:extension",
:path => ":rails_root/public/uploads/products/:id/:style/:basename.:extension",
:styles => { :thumb=> "100x100#" }
the error i see on the console is
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: C:/DOCUME~1/LOCALS~1/Temp/stream,2956,1.jpg is not recognized by the 'identify' command.>
what does this mean? I have no idea what it means. Should i install this ImageMagick?
I tried installing it as a plugin as per this page. This also returns an error that "plugin not found".
what am i missing here?
update: I am on windows xp. webrick server. I have rmagick gem
Run identify on your command prompt. If it identifies itself as ImageMagick, you have it installed. Next, get a jpg that you know opens in a viewer and try identify <image>.jpg. If it shows the image properties, you can be sure you have ImageMagick working properly. If not, depending on your OS, install IM again.
Sometimes, you might have to remove the preinstalled libjpeg and libpng libraries that come installed with your OS, for IM to install properly. Since you are on windows, you need not worry about this. Just follow the installation for windows from here: http://www.imagemagick.org/script/install-source.php and be sure to set the paths right.
in the source of paperclip.rb ,
if you change the line
option.split("'").map{|m| "'#{m}'" }.join("\'")
to the following:
option.split("'").map{|m| "\"#{m}\"" }.join("\'")
it works
Here is the complete changed method:
def quote_command_options(*options)
options.map do |option|
option.split("'").map{|m| "\"#{m}\"" }.join("\\'")
end
end
it means "identify" failed to tell what kind of file you uploaded, that might be caused by a bad file upload but also by a missing ImageMagick. I dont know how that is usually handled on windows.
You need install the ImageMagick
Ubuntu:
sudo apt-get install imagemagick
If you just installed imagemagick and you're on windows, it may help to do a "full reboot". I assume something wasn't stopping properly, and wasn't picking up the new path.
(probably just closing everything will work, but I just went for a full reboot to be sure)

Remove unncessary error raised by paperclip - filename is not recognized by the 'identify' command

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

Paperclip error

I am getting the following error when uploading an image on the admin panel of spree (RoR e-commerce platform):
Paperclip::NotIdentifiedByImageMagickError in Admin/imagesController#create
/tmp/stream.4724.0 is not recognized by the 'identify' command.
Any ideas? Thanks.
It sounds like the wrong identify command (which is part of ImageMagick) is being called (or, perhaps, it isn't installed at all). Can you confirm the path to this command on your server using:
which identify
Once you've determined where this command is installed (e.g. /usr/local/bin) then you can tell Paperclip about it by adding the following to your environment.rb (or production.rb etc) file:
Paperclip.options[:command_path] = '/usr/local/bin/'
(this is for Paperclip 2.2 and above. If you're using an earlier version you should use :image_magick_path not :command_path)
I solved this problem by
$ sudo apt-get install imagemagick
I'm not saying this is the solution but it wouldn't hurt to check your file permissions. Can the user running imagemagick access files in /tmp/ ?

Resources