0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
rack-smusher uses the smusher gem to compress your images dinamically
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

rack-smusher

rack-smusher is a rack middleware to compress (smush) images by using the smusher gem.

It is intended to be used with serve, but it may work with other Rack-based frameworks (Sinatra, I'm looking at you)

Your original images will never be touched. rack-smusher works on copies of your files.

Why?

I like to save Fireworks editable files inside my serve project, and store them in the git repository. Thus, collaborators have access to the source files and can make changes, history is preserved, and life is good.

That, and it seemed like a fun miniproject :)

Usage

Put this in your config.ru:

gem 'rack-smusher'
require 'rack/smusher'

use Rack::Smusher, {
  :source => "app/images",
  :target => "public/images",
  :base_url => "/images/"
}

Now, you can save your editable files in app/images, and rack-smusher will compress and copy them to public/images when the browser requests them. Folder structure will be preserved, so a file saved in app/images/foo/bar.png will be saved to public/images/foo/bar.png.

If for some reason your app uses a different path for images (say, /img/) you can specify it in the :base_url option.