@thi.ng/imago 0.6.11 → 0.7.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 +7 -1
- package/README.md +8 -1
- package/api.d.ts +17 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/ops/icc.d.ts +3 -0
- package/ops/icc.js +17 -0
- package/ops.d.ts +5 -1
- package/ops.js +2 -0
- package/package.json +7 -2
- package/proc.js +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-04-01T13:12:06Z
|
|
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
|
@@ -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
|
|
@@ -344,7 +351,7 @@ For Node.js REPL:
|
|
|
344
351
|
const imago = await import("@thi.ng/imago");
|
|
345
352
|
```
|
|
346
353
|
|
|
347
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 4.
|
|
354
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 4.93 KB
|
|
348
355
|
|
|
349
356
|
## Dependencies
|
|
350
357
|
|
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
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.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "JSON & API-based declarative and extensible image processing trees/pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -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": "
|
|
189
|
+
"gitHead": "4fe9761724f29400047d749b8bb464360527c230\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
|
-
|
|
33
|
-
|
|
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,
|