v0.6.0
This release adds a chromatic command-line interface and a complete user-font management API. It contains breaking changes and removals; see Removals and Compatibility notes before upgrading.
Removals
chromatic.color.iteratorsremoved, along with thehsl_gradient()andrgb_luma_transform()functions it provided.
Compatibility notes
chromatic.userfont renamed to chromatic.userfonts
The top-level user-font registry is renamed so it no longer shadows the chromatic.data.userfont submodule. Update from chromatic import userfont to userfonts.
ColorStr style methods renamed
crossout() is now crossed_out(), sunder() is now underline(), and dunder() is now double_underline().
ansi_format renamed to ansi_type
The ansi_format keyword and attribute is renamed to ansi_type package-wide. This affects ColorStr, SgrSequence, and img2ansi/ansi2img.
named_color tuple key order changed
Tuple keys are now ordered (name, colorspace) instead of (colorspace, name), for example named_color['red', '24b'] where it was previously named_color['24b', 'red'].
CHROMATIC_DATADIR no longer consulted
chromatic.data resolves bundled-file paths statically relative to the package and no longer reads the CHROMATIC_DATADIR environment variable.
Bundled data file locations changed
Images moved under chromatic/data/images/, and the user-font JSON schema moved under chromatic/data/fonts/. Update any code that references these on-disk paths directly.
New features
Command-line interface
Installing the package now provides a chromatic console script (chromatic.__main__:main) with two command groups.
chromatic font manages user fonts, with register, edit, rename, delete, set-default, and list subcommands. list supports --json and prints a colorized table when attached to a terminal. Font commands honor the CHROMATIC_FONTS environment variable, settable per invocation with --font-dir.
chromatic image ansify converts an image to ANSI art, with control over the color space (4b/8b/24b), contrast and white-point equalization, the glyph character set (--ascii, --latin1, --cp437, --cp1252, or a custom --chars string), luminance-based glyph sorting, the default foreground and background colors, and the output target (a file, a directory, stdout, or the system image viewer).
User-font management API
chromatic.data.userfont gains unregister_userfont, delete_userfont, rename_userfont, edit_userfont, and set_default_userfont. Previously only register_userfont was available.
New ColorStr SGR methods
faint() and remove_reset() are added.
Bare string keys for named_color
named_color accepts bare string keys, for example named_color['red'], in addition to (name, colorspace) tuples.
Improvements
Download notifications
Remote data fetches print a notification to stderr before downloading.
Performance improvements and changes
rgb_dispatch resolution rewritten
rgb_dispatch resolves color-name arguments through direct bytecode introspection, with argument positions precomputed at decoration time and lookups cached. This removes the previous per-call inspect and signature-rewriting overhead.
named_color built lazily
chromatic.image submodule lazy-loading
Changes
ColorNamespace construction rewritten
chromatic.color.palette was rewritten so ColorNamespace and its metaclass define color names and values together and wrap each value through a wrapper= callable, replacing the prior scheme that paired name annotations against a positionally-matched value iterable. Normal use of ColorNamespace is unchanged.
ColorStr.__iter__
ColorStr.__iter__ delegates to __len__/__getitem__.
Smaller install footprint
The unused bundled consolas.ttf font (about 459 KB) was dropped from the package.
Fixes
SgrSequence color-index caching
Cached foreground and background color indices no longer go stale after an insertion or deletion. Previously, mutating a sequence could leave the cache pointing at the wrong element, so the wrong parameters were treated as the active colors.
ColorStr.__format__ color-space alias prefix
A color-space alias prefix in a format spec, for example f"{cs:4b<20}", is parsed correctly and applied before the rest of the spec, and the method preserves the ColorStr type. Previously the alias was only recognized as a suffix, so typical specs silently skipped the conversion and returned a plain str.
Full Changelog: v0.5.1...v0.6.0