@thi.ng/imago 0.6.11 → 0.7.1

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**: 2024-03-27T09:53:45Z
3
+ - **Last updated**: 2024-04-08T14:59:29Z
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.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [0.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.7.0) (2024-04-01)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add ICC profile assignment op ([5d022cb](https://github.com/thi-ng/umbrella/commit/5d022cb))
17
+
12
18
  ## [0.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.6.0) (2024-03-06)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 190 standalone projects, maintained as part
10
+ > This is one of 191 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -32,6 +32,7 @@
32
32
  - [gamma](#gamma)
33
33
  - [grayscale](#grayscale)
34
34
  - [hsbl](#hsbl)
35
+ - [icc](#icc)
35
36
  - [nest](#nest)
36
37
  - [output](#output)
37
38
  - [Templated output paths](#templated-output-paths)
@@ -227,6 +228,12 @@ Grayscale conversion
227
228
 
228
229
  Hue, saturation, brightness and lightness adjustments
229
230
 
231
+ ### icc
232
+
233
+ Assign ICC profile (from preset: `p3`, `srgb`, `cmyk` or from file). Can only be
234
+ given directly prior to [output](#output), overrides input ICC (if any) and only
235
+ used if output format actually supports it.
236
+
230
237
  ### nest
231
238
 
232
239
  Performing nested branches/pipelines of operations with no effect on image state
@@ -338,13 +345,19 @@ still WIP...
338
345
  yarn add @thi.ng/imago
339
346
  ```
340
347
 
348
+ ESM import:
349
+
350
+ ```ts
351
+ import * as imago from "@thi.ng/imago";
352
+ ```
353
+
341
354
  For Node.js REPL:
342
355
 
343
356
  ```js
344
357
  const imago = await import("@thi.ng/imago");
345
358
  ```
346
359
 
347
- Package sizes (brotli'd, pre-treeshake): ESM: 4.82 KB
360
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.93 KB
348
361
 
349
362
  ## Dependencies
350
363
 
package/api.d.ts CHANGED
@@ -12,12 +12,18 @@ import type { AvifOptions, Blend, Exif, ExtendWith, FitEnum, GifOptions, Jp2Opti
12
12
  * ```
13
13
  */
14
14
  export type Gravity = "c" | "e" | "n" | "ne" | "nw" | "s" | "se" | "sw" | "w";
15
+ /**
16
+ * See [thi.ng/pixel-dither](https://thi.ng/pixel-dither) for reference
17
+ */
15
18
  export type DitherMode = "atkinson" | "burkes" | "column" | "diffusion" | "floyd" | "jarvis" | "row" | "sierra" | "stucki" | "bayer";
16
19
  export type Dim = [number, number];
17
20
  export type Size = number | Dim;
18
21
  export type Sides = [number, number, number, number];
19
22
  export type SizeRef = "min" | "max" | "w" | "h" | "both";
20
23
  export type SizeUnit = "px" | "%";
24
+ /**
25
+ * If given as array, the color is interpreted as `[r,g,b,a?]`
26
+ */
21
27
  export type Color = string | number[] | {
22
28
  r: number;
23
29
  g: number;
@@ -255,6 +261,17 @@ export interface HSBLSpec extends ProcSpec {
255
261
  b?: number;
256
262
  l?: number;
257
263
  }
264
+ export interface ICCSpec extends ProcSpec {
265
+ op: "icc";
266
+ /**
267
+ * ICC profile preset name
268
+ */
269
+ profile?: "srgb" | "p3" | "cmyk";
270
+ /**
271
+ * ICC profile file path (can be relative)
272
+ */
273
+ path?: string;
274
+ }
258
275
  export interface NestSpec extends ProcSpec {
259
276
  op: "nest";
260
277
  /**
package/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from "./ops/extend.js";
17
17
  export * from "./ops/gamma.js";
18
18
  export * from "./ops/grayscale.js";
19
19
  export * from "./ops/hsbl.js";
20
+ export * from "./ops/icc.js";
20
21
  export * from "./ops/nest.js";
21
22
  export * from "./ops/output.js";
22
23
  export * from "./ops/resize.js";
package/index.js CHANGED
@@ -17,6 +17,7 @@ export * from "./ops/extend.js";
17
17
  export * from "./ops/gamma.js";
18
18
  export * from "./ops/grayscale.js";
19
19
  export * from "./ops/hsbl.js";
20
+ export * from "./ops/icc.js";
20
21
  export * from "./ops/nest.js";
21
22
  export * from "./ops/output.js";
22
23
  export * from "./ops/resize.js";
package/ops/icc.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Processor } from "../api.js";
2
+ export declare const iccProc: Processor;
3
+ //# sourceMappingURL=icc.d.ts.map
package/ops/icc.js ADDED
@@ -0,0 +1,17 @@
1
+ import { illegalArgs } from "@thi.ng/errors";
2
+ import { resolve } from "node:path";
3
+ const iccProc = async (opts, src, ctx) => {
4
+ const $opts = opts;
5
+ if ($opts.profile) {
6
+ ctx.logger.info("setting ICC profile:", $opts.profile);
7
+ return [src.withIccProfile($opts.profile), false];
8
+ } else if ($opts.path) {
9
+ ctx.logger.info("setting ICC profile:", $opts.path);
10
+ ctx.opts.keepICC = false;
11
+ return [src.withIccProfile(resolve($opts.path)), false];
12
+ }
13
+ illegalArgs("require ICC profile name or path");
14
+ };
15
+ export {
16
+ iccProc
17
+ };
package/ops.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { BlurSpec, ColorLayer, CompLayer, CompSpec, CropSpec, DitherSpec, EXIFSpec, ExtendSpec, GammaSpec, GrayscaleSpec, HSBLSpec, ImgLayer, NestSpec, OutputSpec, ProcSpec, RawLayer, ResizeSpec, RotateSpec, SVGLayer, TextLayer } from "./api.js";
1
+ import type { BlurSpec, ColorLayer, CompLayer, CompSpec, CropSpec, DitherSpec, EXIFSpec, ExtendSpec, GammaSpec, GrayscaleSpec, HSBLSpec, ICCSpec, ImgLayer, NestSpec, OutputSpec, ProcSpec, RawLayer, ResizeSpec, RotateSpec, SVGLayer, TextLayer } from "./api.js";
2
2
  /** @internal */
3
3
  export declare const defSpec: <T extends ProcSpec>(op: T["op"]) => (opts: Omit<T, "op">) => T;
4
4
  /** @internal */
@@ -64,6 +64,10 @@ export declare const grayscale: (opts: Omit<GrayscaleSpec, "op">) => GrayscaleSp
64
64
  * Creates a new {@link HSBLSpec} with given opts.
65
65
  */
66
66
  export declare const hsbl: (opts: Omit<HSBLSpec, "op">) => HSBLSpec;
67
+ /**
68
+ * Creates a new {@link ICCSpec} with given opts.
69
+ */
70
+ export declare const icc: (opts: Omit<ICCSpec, "op">) => ICCSpec;
67
71
  /**
68
72
  * Creates a new {@link NestSpec} with given opts.
69
73
  */
package/ops.js CHANGED
@@ -14,6 +14,7 @@ const extend = defSpec("extend");
14
14
  const gamma = defSpec("gamma");
15
15
  const grayscale = defSpec("gray");
16
16
  const hsbl = defSpec("hsbl");
17
+ const icc = defSpec("icc");
17
18
  const nest = defSpec("nest");
18
19
  const output = defSpec("output");
19
20
  const resize = defSpec("resize");
@@ -31,6 +32,7 @@ export {
31
32
  gamma,
32
33
  grayscale,
33
34
  hsbl,
35
+ icc,
34
36
  imageLayer,
35
37
  nest,
36
38
  output,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/imago",
3
- "version": "0.6.11",
3
+ "version": "0.7.1",
4
4
  "description": "JSON & API-based declarative and extensible image processing trees/pipelines",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,23 +36,23 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.9.31",
40
- "@thi.ng/associative": "^6.3.54",
41
- "@thi.ng/blurhash": "^0.1.19",
42
- "@thi.ng/checks": "^3.5.5",
43
- "@thi.ng/date": "^2.7.12",
44
- "@thi.ng/defmulti": "^3.0.34",
45
- "@thi.ng/errors": "^2.5.2",
46
- "@thi.ng/file-io": "^2.0.0",
47
- "@thi.ng/logger": "^3.0.7",
48
- "@thi.ng/pixel": "^6.1.26",
49
- "@thi.ng/pixel-dither": "^1.1.124",
50
- "@thi.ng/prefixes": "^2.3.14",
39
+ "@thi.ng/api": "^8.10.0",
40
+ "@thi.ng/associative": "^6.3.55",
41
+ "@thi.ng/blurhash": "^0.1.20",
42
+ "@thi.ng/checks": "^3.6.0",
43
+ "@thi.ng/date": "^2.7.13",
44
+ "@thi.ng/defmulti": "^3.0.35",
45
+ "@thi.ng/errors": "^2.5.3",
46
+ "@thi.ng/file-io": "^2.0.1",
47
+ "@thi.ng/logger": "^3.0.8",
48
+ "@thi.ng/pixel": "^6.1.27",
49
+ "@thi.ng/pixel-dither": "^1.1.125",
50
+ "@thi.ng/prefixes": "^2.3.15",
51
51
  "sharp": "^0.33.3"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@microsoft/api-extractor": "^7.43.0",
55
- "@thi.ng/vectors": "^7.10.25",
55
+ "@thi.ng/vectors": "^7.10.26",
56
56
  "esbuild": "^0.20.2",
57
57
  "rimraf": "^5.0.5",
58
58
  "typedoc": "^0.25.12",
@@ -64,6 +64,7 @@
64
64
  "bitmap",
65
65
  "blur",
66
66
  "color",
67
+ "conversion",
67
68
  "crop",
68
69
  "composite",
69
70
  "dither",
@@ -71,6 +72,7 @@
71
72
  "fileformat",
72
73
  "gif",
73
74
  "grayscale",
75
+ "icc",
74
76
  "image",
75
77
  "jpeg",
76
78
  "nested",
@@ -152,6 +154,9 @@
152
154
  "./ops/hsbl": {
153
155
  "default": "./ops/hsbl.js"
154
156
  },
157
+ "./ops/icc": {
158
+ "default": "./ops/icc.js"
159
+ },
155
160
  "./ops/nest": {
156
161
  "default": "./ops/nest.js"
157
162
  },
@@ -181,5 +186,5 @@
181
186
  "status": "alpha",
182
187
  "year": 2024
183
188
  },
184
- "gitHead": "ce5ae2a322d50a7ce8ecccbd94fa55c496ba04fd\n"
189
+ "gitHead": "85ac4bd4d6d89f8e3689e2863d5bea0cecdb371c\n"
185
190
  }
package/proc.js CHANGED
@@ -12,6 +12,7 @@ import { extendProc } from "./ops/extend.js";
12
12
  import { gammaProc } from "./ops/gamma.js";
13
13
  import { grayscaleProc } from "./ops/grayscale.js";
14
14
  import { hsblProc } from "./ops/hsbl.js";
15
+ import { iccProc } from "./ops/icc.js";
15
16
  import { nestProc } from "./ops/nest.js";
16
17
  import { outputProc } from "./ops/output.js";
17
18
  import { resizeProc } from "./ops/resize.js";
@@ -29,8 +30,8 @@ const processImage = async (src, specs, opts = {}, parentCtx) => {
29
30
  logger: opts.logger || LOGGER,
30
31
  size: [meta.width, meta.height],
31
32
  exif: parentCtx ? structuredClone(parentCtx.exif) : {},
32
- meta,
33
- opts
33
+ opts: { ...opts },
34
+ meta
34
35
  };
35
36
  if (!parentCtx) {
36
37
  if (meta.exif && opts.keepEXIF) {
@@ -79,6 +80,7 @@ const processor = defmulti(
79
80
  gamma: gammaProc,
80
81
  gray: grayscaleProc,
81
82
  hsbl: hsblProc,
83
+ icc: iccProc,
82
84
  nest: nestProc,
83
85
  output: outputProc,
84
86
  resize: resizeProc,