npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@atesgoral/acb

v0.4.0

Published

Adobe Photoshop Color Book (ACB) encoder and decoder

Downloads

45

Readme

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:

| field | description | | :--------------: | --------------------------------------------------------- | | id | The 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. | | title | The color book title. Photoshop seems to show the | | | filename instead of this. | | description | The color book description. Photoshop doesn't show this | | | anywhere. Use '^R' for the registered trademark symbol | | | (®) and '^C' for the copyright symbol (©). | | colorNamePrefix | The prefix to prepend to every color name. | | colorNamePostfix | The suffix to append to every color name. | | pageSize | The number of colors to show on every color page in the | | | library color picker. The maximum that Photoshop allows | | | is 9. | | pageKey | Which 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. | | colorModel | The color model of the color book. Valid values are: | | | | | | * 'RGB' | | | * 'CMYK' | | | * 'Lab' | | | | | | (import type {ColorModel} from '@atesgoral/acb';) | | colors | And array of color records. |

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

| field | description | | :--------: | --------------------------------------------------------------- | | name | The color name. | | code | A 6-character unique code for the color. | | components | An 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.