rai

Ruby-port of Adaptive Images (http://adaptive-images.com/)


Licenses
CC-BY-3.0/Zed
Install
gem install rai -v 0.0.3

Documentation

Ruby Adaptive-Images

This is a ruby port of Adaptive-Images (http://adaptive-images.com/, originally by Matt Wilcox). It does not contain all features, but it does more or less the same in the same way. It uses ImageMagick (via mini_magick) in stead of GD.

It runs as a sinatra application that can be mounted using Rack.

Installation

gem install rai

Configuration

Put something like this in your config.ru:

require 'rai'

map '/images' do
  Rai::App.set :img_path, '/path/to/your/images'
  Rai::App.set :cache_path, '/path/to/your/cache'
  run Rai::App
end

Settings

:watch_cache

Keep an eye on the cache to see if it needs updating.

Values: true/false

Default: true

:resolutions

Resolution break-points (screen widths).

Value: array

Default: [2560, 1920, 1440, 1024, 768, 480]

:jpg_quality

JPG compression ratio, 0-100.

Value: integer, 0-100

Default: 85

:sharpen

Wether image should be sharpened or not.

Value: true/false

Default: true

:cache_max_age

Browser cache TTL

Value: integer, seconds

Default: 606024*7 (7 days)

:img_path

Where images are placed.

Value: string, path

Default:File.join(File.dirname(FILE), '..', 'images')

:cache_path

Where cached versions are placed.

Value: string, path

Default: File.join(File.dirname(FILE), '..', 'images', 'rai-cache')

:cookie_name

The name of the resolution cookie.

Value: string

Default: rai-resolution

Author

Kim Nørgaard jasen@jasen.dk