Jakub Arnold
Jakub Arnold

Reputation: 87250

Paperclip not working with ImageMagick on Windows

I just downloaded the RJCrop from github featuring use of Paperclip with JCrop. I tried running it on my Linux VPS, which worked just fine, however when I run the same project on my development Windows Vista x64 machine, I get this exception.

[paperclip] identify -format %wx%h 
'C:/Users/darth/AppData/Local/Temp/stream,3420,0.png[0]'

[paperclip] An error was received while processing: 
#<Paperclip::NotIdentifiedByImageMagickError: 
C:/Users/darth/AppData/Local/Temp/stream,3420,0.png 
is not recognized by the 'identify' command.>

[paperclip] identify -format %wx%h 
'C:/Users/darth/AppData/Local/Temp/stream,3420,0.png[0]'

[paperclip] An error was received while processing: 
#<Paperclip::NotIdentifiedByImageMagickError: 
C:/Users/darth/AppData/Local/Temp/stream,3420,0.png 
is not recognized by the 'identify' command.>

Identify is in my PATH

C:\>identify -versrubion
Version: ImageMagick 6.6.5-9 2010-11-15 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

And I also added the

Paperclip.options[:command_path] = File.join("c:", "ImageMagick")

configuration to environments/development.rb, but it didn't help. I'm running Ruby 1.9.2p0.

Upvotes: 0

Views: 1563

Answers (1)

Jakub Arnold
Jakub Arnold

Reputation: 87250

I found the issue.

def shell_quote(string)
  return "" if string.nil? or string.blank?
  if self.class.unix?
    string.split("'").map{|m| "'#{m}'" }.join("\\'")
  else
    %{"#{string}"}
  end
end

The unix? method is defined as

def self.unix?
  File.exist?("/dev/null")
end

which however with Cygwin installed returns true, even when ran in regular cmd (at least for me). So I just rewrote it to return false and it works fine. I also submitted this issue to paperclip on github

Upvotes: 2

Related Questions