views:

364

answers:

5

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

A: 

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.

tliff
it cannot be bad file upload as it works fine if don't mention styles. how do i know if ImageMagick is missing?
ZX12R
bad meaning "the content of your file is broken"for details on paperclip on windows see http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip
tliff
followed the link you mentioned. still no use. now i have installed RMagick and included a patch for temp-file.the console is returning the same error
ZX12R
+1  A: 

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.

Kalyan M
is is necessary to install ImageMagick. How about using rmagick plugin?
ZX12R
rmagick uses ImageMagick to process images. rmagick is just a ruby wrapper for ImageMagick.
Kalyan M
you are right.. it was a problem with my local machine's ImageMagick. The code works fine in my server.. Thanks.
ZX12R
A: 

You need install the ImageMagick

Ubuntu:

sudo apt-get install imagemagick
huacnlee
i use windows OS
ZX12R
+1  A: 

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
Marcelo Valle
A: 

Thanks Marcello Valle, I had similar problem and your solution worked !!!

arun