Ruby on Rails, Paperclip: "ident" command working in cmd but not in the application

I installed ImageMagick on my 64-bit Windows 7 and I have a copy of Paperclip. My User model looks like this:

   class User < ActiveRecord::Base
  # Paperclip
  has_attached_file :photo,
    :styles => {
      :thumb=> "100x100#",
      :small  => "150x150>" }
  end

In paperclip.rb and development.rb, I have:

Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.6.7-Q16'

My _form looks like this:

    <%= form_for(@user, :html => { :multipart => true } )  do |f| %>
  <% if @user.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>

      <ul>
      <% @user.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :username %><br />
    <%= f.text_field :username %>
  </div>
  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :email %><br />
    <%= f.text_field :email %>
  </div>
  <div class="field">
    <%= f.label :crypted_password %><br />
    <%= f.text_field :crypted_password %>
  </div>
  <div class="field">
    <%= f.label :password_salt %><br />
    <%= f.text_field :password_salt %>
  </div>
 <%= f.file_field :photo%>
  <div class="actions">
    <%= f.submit %>
  </div>

<% end %>

enter code here

When loading an image, the following error appears:

[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: C:/Users/John/AppData/Local/Temp/stream20110212-6576-1us1cdl.png is not recognized by the 'identify' command.>  

I can use the identifier in my cmd on this image, and it returns metadata about the image without any problems.

Please help if you can. I’ve been stuck on this issue for more than a day.

+3
source share
3 answers

The following is updated in development.rb and it starts working

Paperclip.options[:command_path] = 'C:/Progra~1/ImageM~1.8-q'

It was on a Windows 2008 32-bit server

+4
source

​​ Paperclip lib/paperclip/command_line.rb .

def full_path(binary)
  [self.class.path, binary].compact.join("/")
end

full_path .

"C:\Program Files\ImageMagick-6.7.0-Q16"/identify

Windows, cmd , .

.

.

Paperclip.options[:command_path] = 'C:/PROGRA~1/IMAGEM~1.0-Q'

. :

dir /x "C:\Program Files*"
dir /x "C:\Program Files\ImageMagick-6.7.0-Q16*"

config\initializers\paperclip.rb.

2.3.11.

class Paperclip::CommandLine
  def full_path(binary)
    [self.class.path, binary].compact.join(File::ALT_SEPARATOR||File::SEPARATOR)
  end
end

identify .

"C:\Program Files\ImageMagick-6.7.0-Q16"\identify

, command_path .

+7

Open a command prompt and enter echo %path%, your imagemagick path should appear there.

Also try changing :command_pathtoC:/Progra~1/ImageM~1

0
source

Source: https://habr.com/ru/post/1791745/


All Articles