@thi.ng/pixel-analysis 0.2.2 → 0.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-06-09T17:24:08Z
3
+ - **Last updated**: 2025-06-24T21:39:38Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -11,6 +11,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
11
11
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
12
12
  and/or version bumps of transitive dependencies.
13
13
 
14
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel-analysis@0.3.0) (2025-06-24)
15
+
16
+ #### 🚀 Features
17
+
18
+ - update dominant color extraction ([58c7ea5](https://github.com/thi-ng/umbrella/commit/58c7ea5))
19
+ - add `AnalysisOpts.dominantFn`
20
+
14
21
  ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel-analysis@0.2.0) (2025-06-02)
15
22
 
16
23
  #### 🚀 Features
package/README.md CHANGED
@@ -80,10 +80,11 @@ For Node.js REPL:
80
80
  const pa = await import("@thi.ng/pixel-analysis");
81
81
  ```
82
82
 
83
- Package sizes (brotli'd, pre-treeshake): ESM: 1.28 KB
83
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.30 KB
84
84
 
85
85
  ## Dependencies
86
86
 
87
+ - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
87
88
  - [@thi.ng/color](https://github.com/thi-ng/umbrella/tree/develop/packages/color)
88
89
  - [@thi.ng/compare](https://github.com/thi-ng/umbrella/tree/develop/packages/compare)
89
90
  - [@thi.ng/math](https://github.com/thi-ng/umbrella/tree/develop/packages/math)
@@ -93,6 +94,8 @@ Package sizes (brotli'd, pre-treeshake): ESM: 1.28 KB
93
94
  - [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
94
95
  - [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)
95
96
 
97
+ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
98
+
96
99
  ## API
97
100
 
98
101
  [Generated API docs](https://docs.thi.ng/umbrella/pixel-analysis/)
package/analyze-colors.js CHANGED
@@ -7,7 +7,7 @@ import { srgb } from "@thi.ng/color/srgb/srgb";
7
7
  import { compareByKey } from "@thi.ng/compare/keys";
8
8
  import { compareNumDesc } from "@thi.ng/compare/numeric";
9
9
  import { fit } from "@thi.ng/math/fit";
10
- import { dominantColors } from "@thi.ng/pixel-dominant-colors";
10
+ import { dominantColorsKmeans } from "@thi.ng/pixel-dominant-colors/kmeans";
11
11
  import { FloatBuffer } from "@thi.ng/pixel/float";
12
12
  import { FLOAT_GRAY } from "@thi.ng/pixel/format/float-gray";
13
13
  import { FLOAT_HSVA } from "@thi.ng/pixel/format/float-hsva";
@@ -33,6 +33,7 @@ const analyzeColors = (img, opts) => {
33
33
  }
34
34
  const imgGray = $img.as(FLOAT_GRAY);
35
35
  const imgHsv = $img.as(FLOAT_HSVA);
36
+ const dominantColors = opts?.dominantFn ?? dominantColorsKmeans;
36
37
  const colors = dominantColors($img, opts?.numColors ?? 4).sort(
37
38
  compareByKey("area", compareNumDesc)
38
39
  );
package/api.d.ts CHANGED
@@ -1,10 +1,17 @@
1
+ import type { Fn2 } from "@thi.ng/api";
1
2
  import type { HSV, Oklch, SRGB } from "@thi.ng/color";
2
3
  import type { FloatBuffer } from "@thi.ng/pixel";
4
+ import type { DominantColor } from "@thi.ng/pixel-dominant-colors";
3
5
  export interface AnalysisOpts {
4
6
  /**
5
7
  * Max. number of dominant colors.
6
8
  */
7
9
  numColors: number;
10
+ /**
11
+ * Dominant color extraction function. By default uses
12
+ * [`dominantColorsKmeans()`](https://docs.thi.ng/umbrella/pixel-dominant-colors/functions/dominantColorsKmeans.html)
13
+ */
14
+ dominantFn: Fn2<FloatBuffer, number, DominantColor[]>;
8
15
  /**
9
16
  * Max. image size (longest side)
10
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/pixel-analysis",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Image color & feature analysis utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,14 +39,15 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/color": "^5.7.40",
42
+ "@thi.ng/api": "^8.11.29",
43
+ "@thi.ng/color": "^5.7.42",
43
44
  "@thi.ng/compare": "^2.4.21",
44
45
  "@thi.ng/math": "^5.11.29",
45
46
  "@thi.ng/pixel": "^7.5.1",
46
47
  "@thi.ng/pixel-convolve": "^1.1.1",
47
- "@thi.ng/pixel-dominant-colors": "^1.1.48",
48
- "@thi.ng/transducers": "^9.4.1",
49
- "@thi.ng/vectors": "^8.3.0"
48
+ "@thi.ng/pixel-dominant-colors": "^2.0.0",
49
+ "@thi.ng/transducers": "^9.4.3",
50
+ "@thi.ng/vectors": "^8.3.1"
50
51
  },
51
52
  "devDependencies": {
52
53
  "esbuild": "^0.25.5",
@@ -106,5 +107,5 @@
106
107
  "status": "beta",
107
108
  "year": 2024
108
109
  },
109
- "gitHead": "14e994e531d32053e948768998324d443436a542\n"
110
+ "gitHead": "45e91ee75236e39fc87ea10fbabac1272bef62e3\n"
110
111
  }