1.0.3 • Published 5 years ago

ase-util v1.0.3

Weekly downloads
32
License
MIT
Repository
github
Last release
5 years ago

ASE Util

Utility library to handle Adobe Swatch Exchange (ASE) files.

npm install ase-util

The package provides JavaScript functions and command line tools.

Command line tools

asedump

Dumps the colors and groups of an .ase file as JSON or LESS format.

Usage: asedump [options] filename.ase

Options:

  • --pretty Pretty print the output
  • --format / -f Output format: json, json-colors, less
    • json: output of ase.read as JSON (includes everything in the ASE file).
    • json-colors: a JSON that contains only color names and hex color values (groups are flattened, CMYK and LAB colors ignored).
    • less: like json-colors but the output is formatted using LESS syntax.
  • --export When using JSON output it adds the CommonJS module.exports

ase2clr

Converts an .ase file to .clr OSX color list.

OSX Only: To do the conversion the tool uses OSX scripting to get a NSColorList instance, in other words it'll not work on other platforms.

Usage: ase2clr input.ase output.clr

API

var ase = require("ase-util");

ase.read(buffer)

var fs = require("fs");
var result = ase.read(fs.readFileSync("myfile.ase"));

Reads a buffer with the ASE binary format; outputs an array with color or color group objects:

Color

There are four kinds of colors: RGB, CMYK, Lab, and Gray.

Color components in ASE files are stored using float values, for instance in RGB component values goes from 0 to 1 (instead of 0 to 255). For RGB and Gray colors, an convenient hex field with the HTML hex color format is included.

Each color value has a type field with the Spot/Process (Normal)/Process Global distinction made by Illustrator and InDesign (see https://helpx.adobe.com/illustrator/using/color.html).

RGB color example:

{
  type: 'color',
  name: 'Color Name',
  color: {model: 'RGB', r: 1, g: 0, b: 0, hex: 'FF0000', type: 'normal'}
}

CMYK color example:

{
  type: 'color',
  name: 'Color Name',
  color: {model: 'CMYK', c: 1, m: 0, y: 0, k: 0, type: 'spot'}
}

LAB color example:

{
  type: 'color',
  name: 'Color Name',
  color: {model: 'LAB', lightness: 1, a: 0, b: 0, type: 'normal'}
}

Gray color example:

{
  type: 'color',
  name: 'Color Name',
  color: {model: 'Gray', gray: 0, hex: '000000', type: 'normal'}
}

Group

Groups are named lists of colors:

{
  type: 'group',
  name: 'Group Name',
  entries: [] // Array of Colors
}

ase.formatAsLess(input, nameEntryFormatFunction)

Takes the output of read and returns a string with LESS variable declarations for the colors.

Only colors with hex values are taken into account (CMYK/LAB colors are ignored).

Color names are formatted using nameEntryFormatFunction, if omitted Lodash's kebabCase will be used.

ase.formatAsColorsObject(input, nameEntryFormatFunction)

Takes the output of read and returns a object with color names and color hex values.

The returned object is useful for contexts where you need only the color/value pairs, i.e. reading the ASE file to use it with PostCSS.

Only colors with hex values are taken into account (CMYK/LAB colors are ignored).

Color names are formatted using nameEntryFormatFunction, if omitted Lodash's kebabCase will be used.

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago