2012-04-10 47 views
2

我使用曲别针在我的Rails应用程序来调整图像,这样如何使定制回形针处理器来调整图像大小

has_attached_file :photo, :styles => { :medium => "300x300>" } 

这让我大小60KB的形象,我想用回形针处理器做一些自定义的方法来减少图像的大小,我该如何做到这一点,我怎么才能直接从这些过程调用imagemagick功能?

感谢

+0

+ 1我怎么能直接从这些过程调用ImageMagick的功能呢? – 2012-06-21 08:32:04

+0

@saurabh - 使用:convert_options,例如 ** has_attached_file:photo,:convert_options => {:name_of_style =>“imagemagick stuff”} ** – 2012-06-27 17:05:49

回答

-1

在我的图片模型:

has_attached_file :picture, 
        :storage => :s3, 
        :s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml", 
        :styles => { :original => "319x228#", :thumb => "100x60#" }, 
        :path => "article/:attachment/:id/:style/:basename.:extension", 
        :bucket => YAML.load_file("#{RAILS_ROOT}/config/amazon_s3.yml")[RAILS_ENV]["bucket_name"] 
    validates_attachment_content_type :picture, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif', 'image/png']