Yesterday I was working on a project, and found myself needing to create a bunch of color swatches. CSS wasn’t an option. No. They had to be little 16x16 images.
In such situations, I often resort to a more-or-less socratic dialog:
“Is it not so that you are building this for a client”
“And do clients not inevitably change their minds”
“Very true, they usually do”
“Then would it not make sense to generate these swatches programmatically?”
The Rake Task
Heartily agreeing with myself, I devised the following rake task for creating color swatches, based on input from a YAML file. BTW, You’ll need to have imagemagick installed.
The YAML File
Now create a “swatches.yml” file like so:
Now you can just type in “rake swatches” and feel the magick.