简体   繁体   中英

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

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM