Reputation: 23395
Does anyone know how to optimize image size through paperclip?
In my Graphic model I have the following:
has_attached_file :graphic,
:styles => {
:home => ['120x90',:jpg],
:thumb => ['70x70',:jpg]
}
By optimize I mean, reduce the filesize of each of :home & :thumb graphics once paperclip creates them, Google's speed test tells me that I should be able to reduce these by 70 - 90%.
I think I can do this by creating a perclip processor, but not really sure where to start.
Kind of stumped on this one, any help / hints much appreciated!
(Rails 2.3)
Upvotes: 3
Views: 3597
Reputation: 1013
And this gem to image compression processor for Paperclip:
https://github.com/emrekutlu/paperclip-compression
Upvotes: 2
Reputation: 4713
There's a gem that allows you to do this easily with Paperclip:
https://github.com/janfoeh/paperclip-optimizer
Upvotes: 3
Reputation: 3015
Check out the quality option. I've read that 75 is the best setting for balancing quality and the resulting size of the image.
has_attached_file :photo,
:styles => {
:small => {
:geometry => '38x38#',
:quality => 40,
:format => 'JPG'
},
:medium => {
:geometry => '92x92#',
:quality => 50
}
Upvotes: 1