README

Path: README
Last Update: Mon May 08 10:50:52 PDT 2006

Asset Compiler

An asset compiler is a build system which transforms a set of media files into the format required by a software project. This asset compiler in particular is a lightweight DSL for defining the necessary build tasks with Rake.

What You‘ll Need

  1. Rake 0.7.0 or greater sudo gem install rake
  2. The Little Color Management System (lcms) for dealing with color profiles
  3. GraphicsMagick or ImageMagick built with lcms. Currently GraphicsMagck is recommended. If you have GraphicsMagick installed, you can run gm -version to verify you’ve built GraphicsMagick with lcms. If you are using ImageMagick, you can run identify -list version to verify that ImageMagick can use lcms.
  4. RMagick

How it’s done

Trivial example for copying a directory of assets:

  asset_task 'old_war_films' do
    from Rake::FileList[SRC_DIR + '/*.mov']
    to   BUILD_DIR

    transformation do |src, target|
      cp src, target
    end
  end

This example defines the following tasks:

  rake assets:build                  # Build all assets
  rake assets:clobber                # Clobber all assets
  rake assets:old_war_films:build    # Build the old_war_films files
  rake assets:old_war_films:clobber  # Remove old_war_films files
  rake assets:old_war_films:rebuild  # Force a rebuild of the old_war_films files
  rake assets:rebuild                # Rebuild all assets

Here is an example that applies a sepia effect to each image in a directory and crops them to 62x62 pixels:

  define_image_transformation 'thumbnailize' do
    crop_to '62x62', :north
  end

  define_image_transformation 'sepia' do
    greyscale
    #    r     g     b     tint
    tint 0.40, 0.25, 0.25, '#eeb030'
  end

  image_task 'thumbnails' do
    from SRC_DIR
    to   BUILD_DIR
    transformation do
      sepia
      thumbnailize
    end
  end

This will define the following tasks:

  rake assets:build                  # Build all assets
  rake assets:clobber                # Clobber all assets
  rake assets:thumbnails:build       # Build the thumbnails files
  rake assets:thumbnails:clobber     # Remove thumbnails files
  rake assets:thumbnails:rebuild     # Force a rebuild of the thumbnails files
  rake assets:rebuild                # Rebuild all assets

[Validate]