2012-04-10 42 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'] 
相關問題