0.0
No commit activity in last 3 years
No release in over 3 years
A wrapper of the paperclip attachment handler that uses sane defaults to optimally compress attached images using imagemagick utility functions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 10.0

Runtime

~> 4.2
 Project Readme

EasyOptimise

A wrapper built on the Paperclip attachment gem. EasyOptimise adds the abililty to optimise image sizes for web using sane defaults for compression and quality. The image optimisation is applied using ImageMagick utility functions.

Installation

Add this line to your application's Gemfile:

gem 'easy_optimise'

And then execute:

$ bundle

Or install it yourself using Rubygems:

$ gem install easy_optimise

Usage

In paperclip you might:

has_attached_file :avatar, 
  styles: { medium: "300x300>",
            thumb:  "100x100>" },
  default_url: "/images/:style/missing.png"

With EasyOptimise, to optimise the images you serve up, just extend the gem in your model:

extend EasyOptimise

and then slip in one sneaky word in your attachment method:

has_attached_optimised_file :avatar,
  styles: { medium: "300x300>",
            thumb:  "100x100>" },
  default_url: "/images/:style/missing.png"

If you want to keep a particular style unoptimised for precise quality (or because you like big slow websites and that's just how you roll), then:

has_attached_optimised_file :avatar,
  styles: { medium: "300x300>",
            thumb:  "100x100>" },
  unoptimised_styles: { banner: "1200x800#" },
  default_url: "/images/:style/missing.png"

Contributing

  1. Fork it ( https://github.com/PhilipCastiglione/easy_optimise/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
  6. Party
                               .--------.
                             .: : :  :___`.
                           .'!!:::::  \\_\ `.
                      : . /%O!!::::::::\\_\. \
                     [""]/%%O!!:::::::::  : . \
                     |  |%%OO!!::::::::::: : . |
                     |  |%%OO!!:::::::::::::  :|
                     |  |%%OO!!!::::::::::::: :|
            :       .'--`.%%OO!!!:::::::::::: :|
          : .:     /`.__.'\%%OO!!!::::::::::::/
         :    .   /        \%OO!!!!::::::::::/
        ,-'``'-. ;          ;%%OO!!!!!!:::::'
        |`-..-'| |   ,--.   |`%%%OO!!!!!!:'
        | .   :| |_.','`.`._|  `%%%OO!%%'
        | . :  | |--'    `--|    `%%%%'
        |`-..-'| ||   | | | |     /__\`-.
        \::::::/ ||)|/|)|)|\|           /
---------`::::'--|._ ~**~ _.|----------( -----------------------
           )(    |  `-..-'  |           \    ______
           )(    |          |,--.       ____/ /  /\\ ,-._.-'
        ,-')('-. |          |\`;/   .-()___  :  |`.!,-'`'/`-._
       (  '  `  )`-._    _.-'|;,|    `-,    \_\__\`,-'>-.,-._
        `-....-'     ````    `--'      `-._       (`- `-._`-.