Duotonics
Duotonics is a Python application for reproducible two-color imaging. It blends random or explicit color pairs over a source image's tonal key in gamma-encoded sRGB (legacy), linear sRGB, or Oklab (Ottosson, 2020). It accepts JPEG, PNG, and BMP input and writes a batch of lossless PNGs (100 by default) plus colors.csv and metrics.csv sidecars. The application is usable through file dialogs, a command-line interface, or as a Python library.
Features
- Image selection via a file dialog
- Generates 100 duotone variations as lossless PNG files (count configurable)
- Filenames use hex color codes in RGB order (e.g.
083_2CD2B4_DC1E5A.png), ready to paste into Figma, Illustrator, or your design system - Produces a
colors.csvsidecar listing every variation's color pair for easy reference and sharing - Produces a
metrics.csvsidecar reporting mean, median, and 95th-percentile CIEDE2000 (Sharma, Wu & Dalal, 2005) for every variation against its Oklab-rendered perceptual reference - Command-line mode with reproducible batches (
--seed), configurable variation count (--count), explicit color pairs (--colors), and blend space (--space srgb|linear|oklab) - Uses OpenCV for efficient image processing
Example batch
One source photograph, 100 duotone variations generated with --count 100 --seed 42 --space oklab:
Source: NASA's photograph of astronaut Eileen Collins, public domain, from the scikit-image astronaut dataset.
Installation
Duotonics requires Python 3.9 or higher. Install it from a source checkout:
git clone https://github.com/MichailSemoglou/duotonics.git
cd duotonics
python -m pip install .
This installs the duotonics command and the duotone_generator Python module. After the PyPI release, installation will also be available with python -m pip install duotonics.
Usage
Interactive mode
Run the command without arguments:
duotonics
Direct script execution remains available from a source checkout:
python3 duotone_generator.py
-
A file dialog will open. Select the image you want to process, then choose an output directory.
-
The script will generate 100 duotone variations in a new folder named
[original_filename]_duotone_variations. Each variation is a lossless PNG file named after its two hex color values (e.g.083_2CD2B4_DC1E5A.png). Acolors.csvfile is also written to the same folder, listing every variation's color pair. -
A message box will appear when the process is complete, indicating the location of the output folder.
Command-line mode
Pass the image path as an argument to run without any dialogs, suitable for scripting and headless environments:
duotonics path/to/image.png [--output-dir DIR] [--count N] [--seed S] [--colors "HEX1,HEX2"] [--space {srgb,linear,oklab}]
-o, --output-dir DIR: place the output folder under DIR instead of alongside the source image.--count N: number of random variations (default: 100).--seed S: reproduce a batch exactly by reusing its seed.--colors "#2CD2B4,#DC1E5A": apply explicit color pairs instead of random ones; repeatable, one variation per pair. Cannot be combined with--countor--seed.--space {srgb,linear,oklab}: where the blend runs.srgb(default) is the legacy gamma-space blend.linearblends linear light (IEC 61966-2-1; Poynton, 2003) andoklabblends in Oklab (Ottosson, 2020); both derive the key from ITU-R BT.709 relative luminance instead of grayscale luma.
The location of the output folder is printed on completion.
Library use
The module can be imported and used as a library, without tkinter installed:
from duotone_generator import convert_to_duotone
folder, records = convert_to_duotone("photo.png", count=25, seed=42, space="oklab")
It returns the output folder path and a list of [index, color_1_hex, color_2_hex] records, one per variation. Each batch also writes metrics.csv, whose rows report the mean, median, and 95th-percentile CIEDE2000 (Sharma, Wu & Dalal, 2005) between that variation and its perceptual reference, defined as the same color pair blended in Oklab over the same key. See the convert_to_duotone docstring for all parameters.
Dependencies
- OpenCV (cv2)
- NumPy
- Tkinter (usually comes pre-installed with Python; only needed for interactive mode)
Requirements
- Python 3.9 or higher
Development
Install the package in editable mode with its development dependencies, then run the test suite with coverage:
python -m pip install -e . -r requirements-dev.txt
pytest --cov --cov-report=term-missing
Build and check the wheel and source distribution with:
python -m build
python -m twine check dist/*
Community
License
MIT. See the LICENSE file for details.
Metadata
Release files for duotonics 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| duotonics-1.0.0.tar.gz | 18.6 kB | With provenance | Details for duotonics-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| duotonics-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for duotonics-1.0.0-py3-none-any.whl |
Total release size: 35.2 kB
Release files / duotonics-1.0.0.tar.gz
| Download URL | duotonics-1.0.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d00f40f7be5160833958010305ecfd752da25eada34e443324c79c8b3767d768
|
|
BLAKE2b-256 checksum How to use checksums |
46c54bd82593cc73684ffd76a0a1099255d49bb350de28ee4559fb5629214c87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / duotonics-1.0.0-py3-none-any.whl
| Download URL | duotonics-1.0.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20cfc4f4fbe10dad77adfd439f2356dd5988cf88d01778dc6883653a0745a8ba
|
|
BLAKE2b-256 checksum How to use checksums |
fd3ead5c23e8b5127afba964d893b8368c0f6bce34cf49e5dcb7e5e594e81f83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for duotonics 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for duotonics-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.