0.4.0 • Published 3 years ago

@atesgoral/acb v0.4.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

acb

npm (scoped) CI TypeScript

Adobe Photoshop Color Book (ACB) encoder and decoder.

What

Adobe Photoshop's color picker allows you to pick colors from standard color libraries. These libraries reside as .acb files inside Photoshop's installation directory (e.g. /Applications/Adobe Photoshop/Presets/Color Books on macOS). This library allows you to decode and encode .acb files. You can extract color data from Photoshop's color books, as well as creating your own custom color books you can use them yourself or distribute them.

image

Install

npm install @atesgoral/acb
# Or:
yarn add @atesgoral/acb

Book structure

The output from the decoder and the expected input into the decoder looks something like this:

const book = {
  id: 42,
  title: 'Primary colors',
  description: 'Primary light colors, as perceived by humans.',
  colorNamePrefix: '',
  colorNamePostfix: '',
  pageSize: 3,
  pageKey: 1,
  colorModel: 'RGB',
  colors: [
    {name: 'Red', code: 'RED   ', components: [255, 0, 0]},
    {name: 'Green', code: 'GREEN ', components: [0, 255, 0]},
    {name: 'Blue', code: 'BLUE  ', components: [0, 0, 255]},
  ],
};

If you're using TypeScript, there is a ColorBook interface that is exported by the library:

import type {ColorBook} from '@atesgoral/acb';

const book: ColorBook = {
  // ...
};

All properties are mandatory:

fielddescription
idThe unique color book identifier. You must ensure that
this does not conflict with an existing color book that
exists in Photoshop's color book folder. Stock Photoshop
color books seem to start at id 3000.
titleThe color book title. Photoshop seems to show the
filename instead of this.
descriptionThe color book description. Photoshop doesn't show this
anywhere. Use '^R' for the registered trademark symbol
(®) and '^C' for the copyright symbol (©).
colorNamePrefixThe prefix to prepend to every color name.
colorNamePostfixThe suffix to append to every color name.
pageSizeThe number of colors to show on every color page in the
library color picker. The maximum that Photoshop allows
is 9.
pageKeyWhich color (by index) on a page to use as the color page
key. For example, with 9 colors per page, 5 would be the
middle of the page color.
colorModelThe color model of the color book. Valid values are:
* 'RGB'
* 'CMYK'
* 'Lab'
(import type {ColorModel} from '@atesgoral/acb';)
colorsAnd array of color records.

Each color record (import type {Color} from '@atesgoral/acb';) consists of the following mandatory properties:

fielddescription
nameThe color name.
codeA 6-character unique code for the color.
componentsAn array of component values. For RGB, it's 3 values 0..255.
For CMYK it's 4 values 0..100. For Lab the L component is
0..100 while a and b are -128..127. (All ranges are inclusive.)

Decoding examples

Decoding from the standard input stream

import {AcbStreamDecoder} from '@atesgoral/acb';

const decoder = new AcbStreamDecoder();

decoder.on('book', (book) => {
  console.log(JSON.stringify(book, null, 2));
});

decoder.on('error', (error) => console.error(error));

process.stdin.pipe(decoder).pipe(process.stdout);

Decoding from a buffer

import {Readable} from 'stream';

import {AcbStreamDecoder} from '@atesgoral/acb';

const decoder = new AcbStreamDecoder();

decoder.on('book', (book) => {
  console.log(JSON.stringify(book, null, 2));
});

decoder.on('error', (error) => console.error(error));

const buffer = fs.readFileSync('./book.acb');

Readable.from(buffer).pipe(decoder).pipe(process.stdout);

Encoding examples

encodeAcb is a generator that yields Buffer chunks.

Encoding to the standard output stream

import {Readable} from 'stream';

import {encodeAcb} from '@atesgoral/acb';

const book = {
  // ...
};

const readable = Readable.from(encodeAcb(book));
readable.pipe(process.stdout);

Encoding into a single Buffer

import {encodeAcb} from '@atesgoral/acb';

const book = {
  // ...
};

const buffer = Buffer.concat([...encodeAcb(book)]);

Background

I reverse-engineered the ACB format back in 2003 before Adobe had it published publicly. I've been creating custom color books on the side for artists, printers and ink manifacturers. I've finally gotten around to publicly publishing a library that everyone can use.

0.3.0

3 years ago

0.4.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.5

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago