user502052 user502052 - 3 months ago 19
Ruby Question

How can I reduce the quality of an uploading image using Paperclip?

I am running Ruby on Rails 3 and I would like to reduce the quality of an uploading image using the Paperclip plugin/gem. How can I do that?




At this time in my model file I have:

has_attached_file :avatar,
:styles => {
:thumb => ["50x50#", :jpg],
:medium => ["250x250#", :jpg],
:original => ["600x600#", :jpg] }


that will convert images in to the
.jpg
format and will set dimensions.

Answer

Try using convert_options.

has_attached_file :avatar, 
                  :styles          => { :thumb => '50x50#' },
                  :convert_options => { :thumb => '-quality 80' }
Comments