paperclip:处理时收到错误

时间:2015-04-14 10:35:03

标签: ruby-on-rails paperclip

我正在尝试使用回形针裁剪图像,但它给了我以下错误:
convert.im6:缺少图像文件名`-crop' @ error / convert.c / ConvertImageCommand / 3046。

[paperclip]处理时收到错误:#Paperclip :: Error:处理334deb7b21e的缩略图时出错 3a70079ee47f9582d6df620150414-10948-1fany48

user.rb:

has_attached_file :image, :styles  => { :small => "100x100#" , :large => "500x500>" }, :processors => [:cropper]
validates_attachment_presence :image
validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/png','image/jpg']
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

def cropping?
!crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
end

def image_geometry(style = :original)
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file(image.path(style))
end

users_controller.rb:

def create
@user = User.new(user_params)
if @user.save
  flash[:notice] = "Successfully created user."

  if params[:user][:image].blank?
  redirect_to @user
  else
  render :action => 'crop'
  end
else
render :action => 'new'
end
end

def update

@user = User.find(params[:id])
session[:user_id] = @user.id
if @user.update_attributes(user_params)
 flash[:notice] = "Successfully updated user."
 if params[:user][:image].blank?
  redirect_to @user
 else
  render :action => 'crop'
 end
else
render :action => 'edit'
end
end


def crop
@user = User.find(params[:id])
@user.update_attributes(crop_params)
@res=@user.image.reprocess!  #crop the image and then save it.
puts @res
redirect_to users_path(@user.id)
end

def user_params
 params.require(:user).permit(:name,:image,:crop_x,:crop_y,:crop_w,:crop_h)
end

def crop_params
params.require(:user).permit(:crop_x, :crop_y, :crop_w, :crop_h)
end

在config / environment / development.rb中添加了以下行:

Paperclip.options [:command_path] =" / usr / bin /"

有关如何解决此问题的任何建议吗?

由于

0 个答案:

没有答案