Simple Python script to extract and generate Adobe Color Swatch (.aco) files.
Project description
Adobe Color Swatch
Description
swatch.py
is a Python 3 command line interface created to extract Color
Swatch data from .aco
files and save them as a simple .csv
. It can also
work in revers and generate a .aco
file based on a .csv
data file.
Installation
Install from GitHub repository:
pip3 install git+https://github.com/kdybicz/adobe-color-swatch
Usage
Extract .aco
usage: swatch extract [-h] -i INPUT -o OUTPUT [-v]
Extract .aco input file to a .csv output file
optional arguments:
-h, --help show this help message and exit
-i INPUT, --input INPUT
input file
-o OUTPUT, --output OUTPUT
output file
-v, --verbose increase output verbosity
Generate .aco
usage: swatch generate [-h] -i INPUT -o OUTPUT [-v]
generate .aco output file based on .csv input file
optional arguments:
-h, --help show this help message and exit
-i INPUT, --input INPUT
input file
-o OUTPUT, --output OUTPUT
output file
-v, --verbose increase output verbosity
Specification
.aco
file format parser and generator were created based on
Adobe Color Swatch File Format Specification.
Script is supporting both version 1 and 2 of the Color Swatch format.
.csv
file is using custom format:
name,space_id,color
RGB Magenta 16-bit,0,#FF00FF
RGB Magenta 32-bit,0,#FFFF0000FFFF
CMYK Magenta 16-bit,2,#FF00FFFF
CMYK Magenta 32-bit,2,#FFFF0000FFFFFFFF
75% Gray,8,#1D4C
Color space IDs
Supported color spaces
ID | Name | Color information |
---|---|---|
0 | RGB | Supports 16 and 32 bit channels, so accordingly 6 or 12 bytes of color information |
1 | HSB | Supports 16 and 32 bit channels, so accordingly 6 or 12 bytes of color information |
2 | CMYK | Supports 16 and 32 bit channels, so accordingly 8 or 16 bytes of color information |
8 | Grayscale | Supports 16 and 32 bit channel, so accordingly 2 or 4 bytes of color information |
NOT supported color spaces
ID | Name |
---|---|
3 | Pantone matching system |
4 | Focoltone colour system |
5 | Trumatch color |
6 | Toyo 88 colorfinder 1050 |
7 | Lab |
10 | HKS colors |
Validation
To validate that the .aco
file generation is working properly I decided on
the following process:
- export few default Color Swatches from Adobe Photoshop 2022
- extract them to
.csv
files and make sure data in that files are matching to what is in the Adobe Photoshop - generate new
.aco
files from.csv
acquired in the previous step - compare original
.aco
files with ones regenerated from.csv
using:
hexdump examples/utf.aco > utf.aco.hex
hexdump utf-new.aco > utf-new.aco.hex
diff utf.aco.hex utf-new.aco.hex -y
- import new
.aco
files into Adobe Photoshop and compare them with original Swatches
Notes
I'm aware that original .aco
files contain some additional bytes at the end
of the files. Those bytes which will not be present in .aco
files generated
by the script. These bytes might be related to
Custom color spaces,
which are not supported by this script.
Nevertheless I was able to successfully import generated .aco
files back into
the Adobe Photoshop and use them in my work!
Development
Testing and linting
For all supported environments:
tox --parallel
Note: running tests for all supported Python versions require to have Python interpreters for those versions to be installed.
For particular environment:
tox -e py39
For running tests in development environment:
tox --devenv venv -e py39
. venv/bin/activate
pytest
Local installation
Install a project in editable mode:
pip3 install -e .
Deployment
Building the packages:
./venv/bin/python setup.py sdist bdist_wheel
Checking if build packages are valid:
twine check dist/*
Uploading to pypi:
twine upload -r pypi dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file adobe_color_swatch-1.0.0.tar.gz
.
File metadata
- Download URL: adobe_color_swatch-1.0.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cfb08400ec11653a696e7bed0656cdde24f6b2166ff1beb3fcbe49df731befe |
|
MD5 | 47f6e97dc781d8676f0e0010b37242d4 |
|
BLAKE2b-256 | 3bff7c6a05fe3e972e9d49167d1dc93ffdfa23f857db464a5b1f97feea8ba6ce |
File details
Details for the file adobe_color_swatch-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: adobe_color_swatch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c8a5128ae25f3d1fe3a58c1e6bf11afa16779da7b7c50fa3903f6eef0044ff3 |
|
MD5 | 078d3d8646a75be955075923d34c6b38 |
|
BLAKE2b-256 | e2f42c4dfa73b1c161820f114baefa98882f0ddb5680087fc1a7e3e81cfb6589 |