Rails减少了一些%的图像大小

时间:2014-08-28 10:51:09

标签: ruby-on-rails paperclip

我需要任何减少图像尺寸的解决方案

我正在使用paperclip

has_attached_file :image, :styles => { :small =>{ :geometry =>"200 x 123>"}}

例如我有原始图像1 Mb和一些魔法之后我想要图像300 Kb 然后将其上传到aws

2 个答案:

答案 0 :(得分:2)

您可以使用convert_options

has_attached_file :image, 
                  :convert_options => { :thumb => '-quality 50' }

或者你可以尝试这个

has_attached_file :image => { :quality => :better } 

参考:Paperclip doc

答案 1 :(得分:2)

看看这个 https://github.com/janfoeh/paperclip-optimizer

它是用于图像优化的宝石。

如果您需要更好的优化,请使用Google PageSpeed模块进行apache或Nginx!

相关问题