Generate Color Book File

Description

“Generate Color Book File” is a color books utility script using the JSON Action Manager scripting library.

This stand-alone script written in JavaScript is used to generate a Photoshop color book file (.acb) from a JSON text file.

It has been put in practice to generate two custom Color Books:

The utility script Parse Color Book File performs the reverse operation, i.e., converts a Photoshop color book file (.acb) into a JSON text file.

The information about the color book file format comes from two main sources:

Two different, mutually exclusive keys are available to list each color in the JSON text file:

  • "rawComponents": raw color components (with values ranging from 0 to 255), or
  • "actualComponents": actual color components (with values converted from the raw color components).

In the second case, when generating the color book file, the actual color components are automatically converted back to the raw color components according to the following formulas:

CMYK color space:

  • components[0] = 255 - Math.round (cyan * 255 / 100);
  • components[1] = 255 - Math.round (magenta * 255 / 100);
  • components[2] = 255 - Math.round (yellowColor * 255 / 100);
  • components[3] = 255 - Math.round (black * 255 / 100);

Lab color space:

  • components[0] = Math.round (luminance * 255 / 100);
  • components[1] = Math.round (a) + 128;
  • components[2] = Math.round (b) + 128;

RGB color space:

  • components[0] = Math.round (red);
  • components[1] = Math.round (green);
  • components[2] = Math.round (blue);

Example

Example of JSON text file (My Color Book.json) used as input to generate a color book file:

{
    "bookID": 42,
    "bookName": "My Color Book 42",
    "colorNamePrefix": "My ",
    "colorNameSuffix": " 42",
    "bookDescription": "Color book example",
    "colorsPerPage": 8,
    "keyColorIndex": 0,
    "colorSpace": "RGB",
    "colors":
    [
        {
            "colorName": "White",
            "colorKey": "W42   ",
            "actualComponents":
            [
                255,
                255,
                255
            ]
        },
        {
            "colorName": "Red",
            "colorKey": "R42   ",
            "actualComponents":
            [
                255,
                0,
                0
            ]
        },
        {
            "colorName": "Yellow",
            "colorKey": "Y42   ",
            "actualComponents":
            [
                255,
                255,
                0
            ]
        },
        {
            "colorName": "Green",
            "colorKey": "G42   ",
            "actualComponents":
            [
                0,
                255,
                0
            ]
        },
        {
            "colorName": "Cyan",
            "colorKey": "C42   ",
            "actualComponents":
            [
                0,
                255,
                255
            ]
        },
        {
            "colorName": "Blue",
            "colorKey": "B42   ",
            "actualComponents":
            [
                0,
                0,
                255
            ]
        },
        {
            "colorName": "Magenta",
            "colorKey": "M42   ",
            "actualComponents":
            [
                255,
                0,
                255
            ]
        },
        {
            "colorName": "Black",
            "colorKey": "K42   ",
            "actualComponents":
            [
                0,
                0,
                0
            ]
        }
    ]
}

Color book (My Color Book.acb) displayed in the Color Libraries dialog (CS4):

Color Libraries Dialog (Mac OS X)

Color book (My Color Book.acb) displayed in the Custom Colors dialog (CS):

Custom Colors Dialog (Mac OS X)

Requirements

This script can be used in Adobe Photoshop CS3 or later. It has been successfully tested in CS4 on Mac OS X, but should be platform agnostic.

Copyright

This Software is copyright © 2013-2016 by Michel MARIANI.

License

This Software is licensed under the GNU General Public License (GPL) v3.

Download

Installation

Download the Zip file and unzip it.

Move the script to the Presets/Scripts folder in the default preset location of the Adobe Photoshop application. On next launch, the script will appear in the File>Automate submenu.

Version History

  • 1.5

    • Handled actual components format in addition to raw components format.
    • Moved file generating code to new jamBooks scripting library module.
    • Used new version 4.5 of jamEngine scripting library module.
  • 1.4

    • Used new version 4.4.4 of jamEngine scripting library module.
  • 1.3

    • Used new version 4.4.1 of scripting library modules.
  • 1.2

    • Fixed generation of output file name.
  • 1.1

    • Used new version 4.0 of scripting library modules.
  • 1.0

    • Initial release.

Tags: , , , ,

Comments are closed.