palettize 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. palettize-0.0.1/.github/workflows/docs.yml +50 -0
  2. palettize-0.0.1/.github/workflows/release.yml +31 -0
  3. palettize-0.0.1/.github/workflows/test.yml +58 -0
  4. palettize-0.0.1/.github/workflows/testindex.yml +28 -0
  5. palettize-0.0.1/.gitignore +25 -0
  6. palettize-0.0.1/.pre-commit-config.yaml +27 -0
  7. palettize-0.0.1/.python-version +1 -0
  8. palettize-0.0.1/CHANGELOG.md +61 -0
  9. palettize-0.0.1/LICENSE +7 -0
  10. palettize-0.0.1/PKG-INFO +225 -0
  11. palettize-0.0.1/README.md +189 -0
  12. palettize-0.0.1/docs/astro.config.mjs +92 -0
  13. palettize-0.0.1/docs/package.json +18 -0
  14. palettize-0.0.1/docs/pnpm-lock.yaml +4384 -0
  15. palettize-0.0.1/docs/public/favicon.svg +12 -0
  16. palettize-0.0.1/docs/src/content/docs/cli/analyze.mdx +114 -0
  17. palettize-0.0.1/docs/src/content/docs/cli/create.mdx +215 -0
  18. palettize-0.0.1/docs/src/content/docs/cli/formats.mdx +106 -0
  19. palettize-0.0.1/docs/src/content/docs/cli/index.mdx +73 -0
  20. palettize-0.0.1/docs/src/content/docs/cli/info.mdx +48 -0
  21. palettize-0.0.1/docs/src/content/docs/cli/list.mdx +93 -0
  22. palettize-0.0.1/docs/src/content/docs/cli/show.mdx +102 -0
  23. palettize-0.0.1/docs/src/content/docs/examples/gis-workflows.mdx +244 -0
  24. palettize-0.0.1/docs/src/content/docs/examples/web-mapping.mdx +339 -0
  25. palettize-0.0.1/docs/src/content/docs/export-formats/css.mdx +265 -0
  26. palettize-0.0.1/docs/src/content/docs/export-formats/gdal.mdx +130 -0
  27. palettize-0.0.1/docs/src/content/docs/export-formats/gee.mdx +185 -0
  28. palettize-0.0.1/docs/src/content/docs/export-formats/gimp.mdx +202 -0
  29. palettize-0.0.1/docs/src/content/docs/export-formats/hex.mdx +188 -0
  30. palettize-0.0.1/docs/src/content/docs/export-formats/hsl.mdx +155 -0
  31. palettize-0.0.1/docs/src/content/docs/export-formats/index.mdx +149 -0
  32. palettize-0.0.1/docs/src/content/docs/export-formats/json.mdx +221 -0
  33. palettize-0.0.1/docs/src/content/docs/export-formats/maplibre-gl.mdx +174 -0
  34. palettize-0.0.1/docs/src/content/docs/export-formats/observable-plot.mdx +184 -0
  35. palettize-0.0.1/docs/src/content/docs/export-formats/qgis.mdx +121 -0
  36. palettize-0.0.1/docs/src/content/docs/export-formats/rgba.mdx +237 -0
  37. palettize-0.0.1/docs/src/content/docs/export-formats/sld.mdx +162 -0
  38. palettize-0.0.1/docs/src/content/docs/export-formats/svg.mdx +263 -0
  39. palettize-0.0.1/docs/src/content/docs/export-formats/titiler.mdx +131 -0
  40. palettize-0.0.1/docs/src/content/docs/getting-started/installation.mdx +81 -0
  41. palettize-0.0.1/docs/src/content/docs/getting-started/quick-start.mdx +129 -0
  42. palettize-0.0.1/docs/src/content/docs/guides/color-interpolation.mdx +192 -0
  43. palettize-0.0.1/docs/src/content/docs/guides/colormap-files.mdx +108 -0
  44. palettize-0.0.1/docs/src/content/docs/guides/custom-exporters.mdx +296 -0
  45. palettize-0.0.1/docs/src/content/docs/guides/data-scaling.mdx +213 -0
  46. palettize-0.0.1/docs/src/content/docs/guides/presets.mdx +234 -0
  47. palettize-0.0.1/docs/src/content/docs/guides/transforms.mdx +130 -0
  48. palettize-0.0.1/docs/src/content/docs/index.mdx +67 -0
  49. palettize-0.0.1/docs/src/content/docs/python-api/colormap.mdx +311 -0
  50. palettize-0.0.1/docs/src/content/docs/python-api/exporters.mdx +228 -0
  51. palettize-0.0.1/docs/src/content/docs/python-api/index.mdx +166 -0
  52. palettize-0.0.1/docs/src/content/docs/python-api/scaling.mdx +217 -0
  53. palettize-0.0.1/docs/src/content.config.ts +7 -0
  54. palettize-0.0.1/docs/src/env.d.ts +1 -0
  55. palettize-0.0.1/docs/src/styles/custom.css +19 -0
  56. palettize-0.0.1/docs/tsconfig.json +3 -0
  57. palettize-0.0.1/pyproject.toml +125 -0
  58. palettize-0.0.1/setup.cfg +4 -0
  59. palettize-0.0.1/src/palettize/__init__.py +157 -0
  60. palettize-0.0.1/src/palettize/analysis.py +372 -0
  61. palettize-0.0.1/src/palettize/cli.py +991 -0
  62. palettize-0.0.1/src/palettize/core.py +755 -0
  63. palettize-0.0.1/src/palettize/exceptions.py +35 -0
  64. palettize-0.0.1/src/palettize/exporters/__init__.py +190 -0
  65. palettize-0.0.1/src/palettize/exporters/_base.py +138 -0
  66. palettize-0.0.1/src/palettize/exporters/_options.py +191 -0
  67. palettize-0.0.1/src/palettize/exporters/css.py +123 -0
  68. palettize-0.0.1/src/palettize/exporters/gdal.py +118 -0
  69. palettize-0.0.1/src/palettize/exporters/gee.py +110 -0
  70. palettize-0.0.1/src/palettize/exporters/gimp.py +86 -0
  71. palettize-0.0.1/src/palettize/exporters/json.py +112 -0
  72. palettize-0.0.1/src/palettize/exporters/mapgl.py +70 -0
  73. palettize-0.0.1/src/palettize/exporters/observable_plot.py +113 -0
  74. palettize-0.0.1/src/palettize/exporters/plaintext.py +163 -0
  75. palettize-0.0.1/src/palettize/exporters/qgis.py +152 -0
  76. palettize-0.0.1/src/palettize/exporters/sld.py +226 -0
  77. palettize-0.0.1/src/palettize/exporters/svg.py +107 -0
  78. palettize-0.0.1/src/palettize/exporters/titiler.py +66 -0
  79. palettize-0.0.1/src/palettize/presets.py +237 -0
  80. palettize-0.0.1/src/palettize/py.typed +0 -0
  81. palettize-0.0.1/src/palettize/render.py +209 -0
  82. palettize-0.0.1/src/palettize/scaling.py +349 -0
  83. palettize-0.0.1/src/palettize.egg-info/PKG-INFO +225 -0
  84. palettize-0.0.1/src/palettize.egg-info/SOURCES.txt +148 -0
  85. palettize-0.0.1/src/palettize.egg-info/dependency_links.txt +1 -0
  86. palettize-0.0.1/src/palettize.egg-info/entry_points.txt +2 -0
  87. palettize-0.0.1/src/palettize.egg-info/requires.txt +10 -0
  88. palettize-0.0.1/src/palettize.egg-info/scm_file_list.json +144 -0
  89. palettize-0.0.1/src/palettize.egg-info/scm_version.json +8 -0
  90. palettize-0.0.1/src/palettize.egg-info/top_level.txt +1 -0
  91. palettize-0.0.1/tests/__init__.py +1 -0
  92. palettize-0.0.1/tests/conftest.py +103 -0
  93. palettize-0.0.1/tests/golden/css/css_all.css +12 -0
  94. palettize-0.0.1/tests/golden/css/css_bare.css +2 -0
  95. palettize-0.0.1/tests/golden/css/default.css +7 -0
  96. palettize-0.0.1/tests/golden/gdal/default.txt +6 -0
  97. palettize-0.0.1/tests/golden/gdal/gdal_no_nodata.txt +4 -0
  98. palettize-0.0.1/tests/golden/gdal/gdal_precision.txt +4 -0
  99. palettize-0.0.1/tests/golden/gdal/gdal_verbose.txt +8 -0
  100. palettize-0.0.1/tests/golden/gdal/log_scaled.txt +6 -0
  101. palettize-0.0.1/tests/golden/gee/default.js +1 -0
  102. palettize-0.0.1/tests/golden/gee/gee_sld.js +8 -0
  103. palettize-0.0.1/tests/golden/gee/log_scaled.js +1 -0
  104. palettize-0.0.1/tests/golden/gimp/default.gpl +9 -0
  105. palettize-0.0.1/tests/golden/gimp/gimp_plain.gpl +7 -0
  106. palettize-0.0.1/tests/golden/hex/default.txt +5 -0
  107. palettize-0.0.1/tests/golden/hex/hex_csv.txt +1 -0
  108. palettize-0.0.1/tests/golden/hex/hex_json.txt +6 -0
  109. palettize-0.0.1/tests/golden/hsl/default.txt +5 -0
  110. palettize-0.0.1/tests/golden/hsl/hsl_tuple.txt +3 -0
  111. palettize-0.0.1/tests/golden/json/default.json +7 -0
  112. palettize-0.0.1/tests/golden/json/json_compact.json +1 -0
  113. palettize-0.0.1/tests/golden/json/json_full.json +14 -0
  114. palettize-0.0.1/tests/golden/json/json_objects.json +17 -0
  115. palettize-0.0.1/tests/golden/json/log_scaled.json +7 -0
  116. palettize-0.0.1/tests/golden/mapgl/default.json +20 -0
  117. palettize-0.0.1/tests/golden/mapgl/log_scaled.json +20 -0
  118. palettize-0.0.1/tests/golden/mapgl/mapgl_precision.json +16 -0
  119. palettize-0.0.1/tests/golden/observable/default.json +16 -0
  120. palettize-0.0.1/tests/golden/observable/log_scaled.json +16 -0
  121. palettize-0.0.1/tests/golden/observable/obs_diverging.json +16 -0
  122. palettize-0.0.1/tests/golden/qgis/default.xml +10 -0
  123. palettize-0.0.1/tests/golden/qgis/log_scaled.xml +10 -0
  124. palettize-0.0.1/tests/golden/qgis/qgis_exact.xml +8 -0
  125. palettize-0.0.1/tests/golden/qgis/qgis_opacity.xml +9 -0
  126. palettize-0.0.1/tests/golden/rgba/default.txt +5 -0
  127. palettize-0.0.1/tests/golden/rgba/rgba_alpha_float.txt +3 -0
  128. palettize-0.0.1/tests/golden/sld/default.sld +24 -0
  129. palettize-0.0.1/tests/golden/sld/log_scaled.sld +24 -0
  130. palettize-0.0.1/tests/golden/sld/sld_11.sld +27 -0
  131. palettize-0.0.1/tests/golden/sld/sld_values.sld +22 -0
  132. palettize-0.0.1/tests/golden/svg/default.svg +9 -0
  133. palettize-0.0.1/tests/golden/svg/svg_full.svg +12 -0
  134. palettize-0.0.1/tests/golden/svg/svg_radial.svg +7 -0
  135. palettize-0.0.1/tests/golden/titiler/default.txt +1 -0
  136. palettize-0.0.1/tests/golden/titiler/titiler_3.txt +1 -0
  137. palettize-0.0.1/tests/test_analysis.py +163 -0
  138. palettize-0.0.1/tests/test_cli.py +514 -0
  139. palettize-0.0.1/tests/test_core.py +330 -0
  140. palettize-0.0.1/tests/test_exporters.py +849 -0
  141. palettize-0.0.1/tests/test_golden.py +191 -0
  142. palettize-0.0.1/tests/test_options.py +196 -0
  143. palettize-0.0.1/tests/test_presets.py +119 -0
  144. palettize-0.0.1/tests/test_public_api.py +100 -0
  145. palettize-0.0.1/tests/test_registry.py +259 -0
  146. palettize-0.0.1/tests/test_render.py +157 -0
  147. palettize-0.0.1/tests/test_scaling.py +216 -0
  148. palettize-0.0.1/tests/test_serialization.py +126 -0
  149. palettize-0.0.1/tests/test_transforms.py +232 -0
  150. palettize-0.0.1/uv.lock +473 -0
@@ -0,0 +1,50 @@
1
+ name: Deploy Documentation to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ check-deploy:
15
+ runs-on: ubuntu-latest
16
+ outputs:
17
+ should_deploy: ${{ steps.check.outputs.should_deploy }}
18
+ steps:
19
+ - name: Check commit message for [gh-pages]
20
+ id: check
21
+ run: |
22
+ if [[ "${{ github.event.head_commit.message }}" == *"[gh-pages]"* ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
23
+ echo "should_deploy=true" >> $GITHUB_OUTPUT
24
+ else
25
+ echo "should_deploy=false" >> $GITHUB_OUTPUT
26
+ fi
27
+
28
+ build:
29
+ needs: check-deploy
30
+ if: needs.check-deploy.outputs.should_deploy == 'true'
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - name: Checkout
34
+ uses: actions/checkout@v4
35
+
36
+ - name: Build with Astro
37
+ uses: withastro/action@v2
38
+ with:
39
+ path: docs
40
+
41
+ deploy:
42
+ needs: build
43
+ runs-on: ubuntu-latest
44
+ environment:
45
+ name: github-pages
46
+ url: ${{ steps.deployment.outputs.page_url }}
47
+ steps:
48
+ - name: Deploy to GitHub Pages
49
+ id: deployment
50
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,31 @@
1
+ name: Release to PyPI
2
+ on:
3
+ push:
4
+ tags: ['v*']
5
+ permissions:
6
+ contents: read
7
+ id-token: write
8
+ jobs:
9
+ # Nothing reaches PyPI unless the full test, lint, and type-check matrix is green.
10
+ test:
11
+ uses: ./.github/workflows/test.yml
12
+
13
+ publish:
14
+ needs: test
15
+ runs-on: ubuntu-latest
16
+ environment: pypi
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - uses: astral-sh/setup-uv@v5
23
+ - run: uv build
24
+
25
+ - name: Verify the built CLI runs
26
+ run: |
27
+ uv run --isolated --no-project --with dist/*.whl palettize --version
28
+ uv run --isolated --no-project --with dist/*.whl palettize formats
29
+
30
+ - name: Publish to PyPI
31
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,58 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_call:
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ with:
21
+ # setuptools_scm derives the version from tags.
22
+ fetch-depth: 0
23
+
24
+ - uses: astral-sh/setup-uv@v5
25
+ with:
26
+ enable-cache: true
27
+
28
+ - name: Run tests with coverage
29
+ run: >
30
+ uv run --python ${{ matrix.python-version }} --extra dev
31
+ pytest --cov=src/palettize --cov-report=xml --cov-report=term-missing
32
+
33
+ - name: Upload coverage to Codecov
34
+ if: matrix.python-version == '3.12'
35
+ uses: codecov/codecov-action@v4
36
+ with:
37
+ files: ./coverage.xml
38
+ fail_ci_if_error: false
39
+
40
+ quality:
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+ with:
45
+ fetch-depth: 0
46
+
47
+ - uses: astral-sh/setup-uv@v5
48
+ with:
49
+ enable-cache: true
50
+
51
+ - name: Ruff lint
52
+ run: uv run --extra dev ruff check src/ tests/
53
+
54
+ - name: Ruff format check
55
+ run: uv run --extra dev ruff format --check src/ tests/
56
+
57
+ - name: Mypy
58
+ run: uv run --extra dev mypy src/palettize --ignore-missing-imports
@@ -0,0 +1,28 @@
1
+ name: Test release on TestPyPI
2
+ on:
3
+ push:
4
+ tags: ['test*']
5
+ permissions:
6
+ contents: read
7
+ id-token: write
8
+ jobs:
9
+ test:
10
+ uses: ./.github/workflows/test.yml
11
+
12
+ publish:
13
+ needs: test
14
+ runs-on: ubuntu-latest
15
+ environment: testpypi
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - uses: astral-sh/setup-uv@v5
22
+ - run: uv build
23
+
24
+ - name: Verify the built CLI runs
25
+ run: uv run --isolated --no-project --with dist/*.whl palettize --version
26
+
27
+ - name: Publish to TestPyPI
28
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,25 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+ .pytest_cache/
9
+ .coverage
10
+ coverage.xml
11
+ htmlcov/
12
+
13
+ # Virtual environments
14
+ .venv
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ .cursor
18
+ /project_docs/
19
+ .DS_Store
20
+
21
+ # Docs site build output
22
+ .astro/
23
+ node_modules/
24
+ docs/dist/
25
+ docs/.pagefind/
@@ -0,0 +1,27 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.6.0
4
+ hooks:
5
+ - id: trailing-whitespace
6
+ # Golden files are compared byte for byte.
7
+ exclude: ^tests/golden/
8
+ - id: end-of-file-fixer
9
+ exclude: ^tests/golden/
10
+ - id: check-yaml
11
+ - id: check-toml
12
+ - id: check-added-large-files
13
+ - id: check-merge-conflict
14
+
15
+ - repo: https://github.com/astral-sh/ruff-pre-commit
16
+ rev: v0.8.3
17
+ hooks:
18
+ - id: ruff
19
+ args: [--fix]
20
+ - id: ruff-format
21
+
22
+ - repo: https://github.com/pre-commit/mirrors-mypy
23
+ rev: v1.13.0
24
+ hooks:
25
+ - id: mypy
26
+ args: [--ignore-missing-imports]
27
+ exclude: ^tests/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ ## [0.0.1] - 2026-09-22
4
+
5
+ ### Added
6
+
7
+ - `palettize analyze` checks lightness, perceptual step size, and color vision (protanopia, deuteranopia, tritanopia). `--json` prints a report; `--strict` exits non-zero when problems are found.
8
+ - Colormap transforms, each returning a new map: `reversed()`, `cut()`, `resampled()`, `quantized()`, `blend()`, and `concat()` / `+`. The CLI exposes them as `--reverse`, `--cut`, and `--steps`.
9
+ - Portable colormap files. `Colormap.save()` / `load()` and `palettize create --save` write JSON that any command accepts in place of a preset name.
10
+ - `palettize show --output` writes a PNG or SVG preview, with no image library required.
11
+ - Preset discovery: `list presets --search/--category/--namespace/--swatch/--limit`, `list categories`, and `palettize presets <name>`.
12
+ - `palettize formats` lists export formats and the options each one accepts.
13
+ - Bulk sampling (`hex_colors`, `rgb_colors`, `rgba_colors`, `hsl_colors`, `colors`) and colormap protocols (`__call__`, `__len__`, `__iter__`).
14
+ - `palettize info` prints the version, links, and a banner.
15
+ - More `get_color()` formats: `hsl_tuple`, `hsl_string`, `rgb_float`, `rgba_float`, `oklch_string`, `css_color`, plus `output_space="display-p3"`.
16
+ - New exporters: `json`, `css`, `hsl`, `gimp`, and `svg`. `hex` and `rgba` gained output-format options.
17
+
18
+ ### Changed
19
+
20
+ - Interpolation uses ColorAide, so multi-stop maps follow the correct hue path. Existing maps sample the same colors.
21
+ - `-v` works after a subcommand, and diagnostics go to stderr.
22
+ - `-O` values are coerced from the format's declared options. Unknown keys warn. `palettize formats` says which formats use `--domain` and `--scale`.
23
+ - GDAL omits the comment header unless `-v` is set, and emits an `nv` nodata line unless `-O nodata=false`.
24
+ - Minimum Python is 3.10.
25
+
26
+ ### Fixed
27
+
28
+ - RGB tuples no longer break later color calls by shadowing ColorAide's `alpha()` method. An alpha of `0.5` on byte RGB stays half-opaque.
29
+ - Colormap files accept only schema version 1. JSON `true`, `0`, and newer versions are refused.
30
+ - SLD no longer builds a reversed `ColorStop` on its fallback path. GEE escapes attribute values.
31
+ - Stop positions are rounded on construction, so chained cuts and a save/load round-trip stay exact.
32
+ - A global `-O` typo warns, the same way a namespaced one does. `nodata=false` suppresses a GDAL nodata line even when `nodata_value` is set.
33
+ - CSS selectors, GIMP palette names, and SVG gradient ids can no longer break out of the file they generate.
34
+
35
+ ### Internal
36
+
37
+ - Golden-file tests cover every exporter (`pytest --update-golden` to accept an intentional format change). CI runs on `uv` and gates releases on the test matrix.
38
+ - The exporter registry loads on demand. Unused `webcolors` dependency removed.
39
+
40
+ ## [0.0.1a2] - 2025-07-13
41
+
42
+ ### Added
43
+
44
+ - Support for exporting colormaps to GEE. CSS-like array of strings (default) or GEE-flavored SLD color ramp XML (sld).
45
+
46
+
47
+
48
+ ## [0.0.1a1] - 2025-07-06
49
+ Alpha release of Palettize.
50
+
51
+ ### Added
52
+
53
+ - Initialized basic project structure, core logic, basic plugin system, and CLI.
54
+ - Support for creating colormaps from preset palettes from `cmap` dependency.
55
+ - Support for exporting colormaps to various formats.
56
+ - GDAL gdaldem color-relief txt format
57
+ - QGIS color ramp XML
58
+ - SLD color ramp XML
59
+ - Titiler url encoded colormap string
60
+ - Mapgl color interpolation expression
61
+ - Observable Plot color object
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Alex Kovac
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,225 @@
1
+ Metadata-Version: 2.4
2
+ Name: palettize
3
+ Version: 0.0.1
4
+ Summary: A Python CLI and library for previewing, checking, and exporting colormaps.
5
+ Author-email: Alex Kovac <5686693+kovaca@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://kovaca.github.io/palettize
8
+ Project-URL: Repository, https://github.com/kovaca/palettize
9
+ Project-URL: Changelog, https://github.com/kovaca/palettize/blob/main/CHANGELOG.md
10
+ Keywords: colormap,palette,visualization,gis,gdal,qgis,cli
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Multimedia :: Graphics
21
+ Classifier: Topic :: Scientific/Engineering :: Visualization
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: coloraide>=4.0
27
+ Requires-Dist: typer>=0.9
28
+ Requires-Dist: rich>=13.0
29
+ Requires-Dist: cmap>=0.6.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.3.5; extra == "dev"
32
+ Requires-Dist: pytest-cov>=6.1.1; extra == "dev"
33
+ Requires-Dist: ruff; extra == "dev"
34
+ Requires-Dist: mypy; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ # Palettize
38
+
39
+ 🎨 A Python utility and CLI tool for generating, previewing, and exporting colormaps.
40
+
41
+ Palettize helps create colormaps for data visualization, GIS, and web mapping. It provides a simple command-line interface to:
42
+
43
+ - Generate colormaps from a list of colors or from built-in presets.
44
+ - Preview colormaps directly in the terminal.
45
+ - Export colormaps to various formats suitable for different applications.
46
+ - Customize interpolation color space, data scaling, and slicing.
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ # Run it without installing
52
+ uvx palettize show viridis
53
+
54
+ # Or install it
55
+ uv pip install palettize
56
+ pip install palettize
57
+ ```
58
+
59
+ ## Quick tour
60
+
61
+ ```bash
62
+ palettize show viridis # preview a colormap in the terminal
63
+ palettize analyze viridis # check it for perceptual problems
64
+ palettize list presets --search blue # find a colormap
65
+ palettize formats # see the export formats
66
+ palettize create viridis -f gdal -o ramp.txt --domain 0,3000
67
+ ```
68
+
69
+ ### Preview
70
+
71
+ ```bash
72
+ palettize show viridis # full-width gradient bar
73
+ palettize show viridis --steps 7 --hex # 7 discrete bands, with hex codes
74
+ palettize show -c "midnightblue,orange,gold" # a colormap of your own
75
+ palettize show viridis -o preview.png # write a PNG or SVG instead
76
+ ```
77
+
78
+ ### Analyze
79
+
80
+ `palettize analyze` answers the question that actually matters: is this colormap safe to
81
+ publish? It reports whether lightness increases steadily, whether equal data steps look
82
+ equally different, and how the map degrades for each form of color vision deficiency.
83
+
84
+ ```bash
85
+ palettize analyze cividis
86
+ palettize analyze jet --strict # exit non-zero when problems are found, for CI
87
+ palettize analyze viridis --json # machine-readable
88
+ ```
89
+
90
+ ```
91
+ cividis 256 stops
92
+
93
+ original ████████████████████████████████████████
94
+ protan ████████████████████████████████████████ 96% kept ok
95
+ deutan ████████████████████████████████████████ 87% kept ok
96
+ tritan ████████████████████████████████████████ 72% kept ok
97
+
98
+ lightness sequential, ascending
99
+ ▁▁▁▁▂▂▂▂▃▃▃▃▄▄▄▄▅▅▅▅▆▆▆▆▇▇▇▇████
100
+ range 66 of 100
101
+ uniformity variation 0.16 (even)
102
+ step size mean 2.8 ΔE, range 1.6-3.7
103
+
104
+ No problems detected.
105
+ ```
106
+
107
+ ### Export
108
+
109
+ ```bash
110
+ # A GDAL color-relief ramp over your data's actual range
111
+ palettize create viridis -f gdal -o elevation.txt --domain 0,3000
112
+
113
+ # Several formats at once, with a filename pattern
114
+ palettize create -c "blue,white,red" -f qgis,mapgl \
115
+ -o "out/{name}_{format}.{ext}" --steps 11 --name RedWhiteBlue
116
+
117
+ # Non-linear scaling, for skewed data
118
+ palettize create viridis -f gdal --domain 1,10000 --scale log
119
+
120
+ # Format-specific options
121
+ palettize create viridis -f gdal -O gdal:nodata=false
122
+ ```
123
+
124
+ Run `palettize formats <name>` to see exactly which options a format accepts, with types and
125
+ defaults — no guessing.
126
+
127
+ ### Transform and reuse
128
+
129
+ Every command accepts `--reverse`, `--cut`, and `--steps`, and any colormap can be saved to a
130
+ portable JSON file and used anywhere a preset name would be:
131
+
132
+ ```bash
133
+ palettize create viridis --cut 0.2,0.8 --reverse --save my-map.json
134
+ palettize show my-map.json
135
+ palettize create my-map.json -f css -o theme.css
136
+ ```
137
+
138
+ ## Python API
139
+
140
+ ```python
141
+ from palettize import Colormap, analyze, create_colormap, get_scaler_by_name
142
+
143
+ cmap = Colormap.from_preset("viridis")
144
+
145
+ # Sampling
146
+ cmap(0.5) # '#21918d'
147
+ cmap.hex_colors(5) # ['#440154', '#3b528b', '#21918d', '#5cc863', '#fde725']
148
+ cmap.rgb_colors(5)
149
+ len(cmap) # 256 stops
150
+
151
+ # Transforms all return new colormaps
152
+ cmap.reversed() # name becomes 'viridis_r'
153
+ cmap.cut(0.2, 0.8) # a sub-range; cuts compose
154
+ cmap.resampled(11) # refit to 11 evenly spaced stops
155
+ cmap.quantized(5) # 5 hard-edged bands
156
+ cmap.blend(Colormap.from_preset("magma"), 0.5)
157
+ cmap + Colormap.from_preset("magma") # concatenate
158
+
159
+ # Save and reload
160
+ cmap.reversed().save("my-map.json")
161
+ Colormap.load("my-map.json")
162
+
163
+ # Perceptual analysis
164
+ report = analyze(cmap)
165
+ report.lightness.shape # 'sequential'
166
+ report.uniformity.is_uniform # True
167
+ report.warnings # plain-language descriptions of any problems
168
+
169
+ # Map data values onto colors
170
+ scaler = get_scaler_by_name("log", domain_min=1, domain_max=1000)
171
+ cmap.apply_scaler(250, scaler)
172
+
173
+ # Or start from a list of colors
174
+ create_colormap(colors=["#0000ff", "white", "#ff0000"], name="BlueWhiteRed")
175
+ ```
176
+
177
+ ## Export formats
178
+
179
+ | Format | Identifier | Use case |
180
+ | --- | --- | --- |
181
+ | GDAL color relief | `gdal` | `gdaldem` raster styling |
182
+ | QGIS color ramp | `qgis` | QGIS styles |
183
+ | OGC SLD | `sld` | GeoServer, MapServer |
184
+ | TiTiler | `titiler` | Tile server URL parameter |
185
+ | MapLibre GL | `mapgl` | Web map style expressions |
186
+ | Observable Plot | `observable` | Plot scale definitions |
187
+ | Google Earth Engine | `gee` | GEE JavaScript snippets |
188
+ | CSS | `css` | Custom properties |
189
+ | SVG | `svg` | Gradient definitions |
190
+ | GIMP palette | `gimp` | GIMP, Inkscape, Krita |
191
+ | JSON | `json` | Generic interchange |
192
+ | Hex / RGBA / HSL | `hex`, `rgba`, `hsl` | Plain text color lists |
193
+
194
+ `palettize formats` lists these with their file extensions; `palettize formats <name>` shows
195
+ each one's options.
196
+
197
+ ## Features
198
+
199
+ - **~650 presets** from the [`cmap`](https://github.com/tlambert03/cmap) catalog, searchable
200
+ by name, category, and publisher.
201
+ - **Perceptual interpolation** in any ColorAide space (Oklch by default), with correct hue
202
+ paths and gamut handling.
203
+ - **Perceptual analysis** built in: lightness monotonicity, ΔE2000 uniformity, and
204
+ colorblind simulation for protanopia, deuteranopia, and tritanopia.
205
+ - **Composable transforms** — reverse, cut, resample, quantize, blend, concatenate.
206
+ - **Portable colormap files** you can save, share, and feed back into any command.
207
+ - **Plugin system** for third-party export formats via the `palettize.exporters` entry point.
208
+ - **No image dependencies** — PNG output is written with the standard library alone.
209
+
210
+ ## Development
211
+
212
+ ```bash
213
+ uv sync --extra dev
214
+ uv run pytest # run the tests
215
+ uv run pytest --update-golden # accept intentional export-format changes
216
+ uv run ruff check src/ tests/
217
+ uv run mypy src/palettize
218
+ ```
219
+
220
+ Exporter output is covered by golden-file tests. When you deliberately change a format, run
221
+ `pytest --update-golden` and review the resulting diff before committing.
222
+
223
+ ## License
224
+
225
+ MIT