Rails 请教关于 paperclip 的图片切割问题

blackangel_can · 2014年04月30日 · 最后由 blackangel_can 回复于 2014年05月11日 · 2071 次阅读

坛子里的帖子看了很久,对着上面的代码也实验了很多次。 发现完全按照上面的代码写出来的模块并没有实现图片切割功能。

class Product < ActiveRecord::Base
  attr_accessible :description, :price,:title, :pro_type, :author, :size
  #确保是数字
  validates_numericality_of :price

  attr_accessible :avatar
  has_attached_file :avatar,
                    :styles => {
                        thumb: '100x100>',
                        square: '200x200#',
                        medium: '300x300>'
                    },
                    :default_url => "/images/:style/missing.png"
  #确定只能传输图片![](//l.ruby-china.com/photo/2014/014b05df8f4d0c2c56dc84699f4ffc26.png)
  validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
  #确保不为空
  validates_presence_of :title,:pro_type,:author,:price,:avatar
end

上传结果是在 system/products/avatars/000/000/002/original/a.png 并没有发现图片有任何裁剪。 请教各位是如何使用的?

没装 imagemagic

#2 楼 @xyuanu 感谢,已经通过其他会员搞定了。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号