简体   繁体   中英

Paperclip + ImageMagick on Windows 7: Image display fails when I add styles to attached_file in model

I'm working with Ruby on rails 2.3.8, NetBeans IDE.

I've installed paperclip and I could show/save images successfully. Now, I've installed ImageMagick-6.6.2-4-Q16(for windows 7, 64bits).

Until that moment, my model looked like this(and worked fine):

has_attached_file :photo

Now, after installing ImageMagick, when I add the :style line it fails:

has_attached_file :photo,
    :styles => {:thumb => "100x100#",   :small => "150x150>",   :large => "400x400>" }

and it throws the following error message when I try to upload an image:

 TypeError in ProfilesController#update

backtrace must be Array of String

The only thing I'm doing in the update action of that controller is the following:

  @profile.update_attributes(params[:profile])
  @profile.update_attribute(:photo, params[:profile][:photo])

I've also installed miniMagick gem(because I read somewhere I had to do it).

What am I missing?

I'll show you what it worked for us:

There is a name conflict with "convert" command. Paperclips tries to run "convert" as is, but this command is already included in the Windows installations as a filesystem converter (FAT to NTFS or something).

If you try to run "convert" from command line, probably will run the mentioned converter instead of imagemagick's "convert" It depends on the PATH environment variable.

If we set imagemagick's path FIRST in the PATH variable it will resolve this path first, so the windows' command won't be executed.

In order to fix it on our rails application, we added

...
if Sys::Uname.sysname == "Linux"
...
else
  ....
   ENV['PATH'] = Paperclip.options[:command_path] + ";" + ENV['PATH']
end
...

on production.rb

尝试下载回形针版本2.3.1.1,但更高的版本对我来说却失败了。

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