@thi.ng/imago 0.5.2 → 0.6.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 +8 -1
- package/README.md +1 -1
- package/api.d.ts +16 -1
- package/package.json +17 -16
- package/proc.d.ts +7 -4
- package/proc.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-03-
|
|
3
|
+
- **Last updated**: 2024-03-07T20:40:47Z
|
|
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,13 @@ 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.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.6.0) (2024-03-06)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- update ImgProcOpts/Ctx, add custom env object ([2b160e0](https://github.com/thi-ng/umbrella/commit/2b160e0))
|
|
17
|
+
- update processImage() & result
|
|
18
|
+
|
|
12
19
|
## [0.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.5.0) (2024-03-01)
|
|
13
20
|
|
|
14
21
|
#### 🚀 Features
|
package/README.md
CHANGED
package/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { Fn, Fn3, Keys, Range1_4, TypedArray } from "@thi.ng/api";
|
|
2
|
+
import type { Fn, Fn3, IObjectOf, Keys, Range1_4, TypedArray } from "@thi.ng/api";
|
|
3
3
|
import type { ILogger } from "@thi.ng/logger";
|
|
4
4
|
import type { AvifOptions, Blend, Exif, ExtendWith, FitEnum, GifOptions, Jp2Options, JpegOptions, JxlOptions, KernelEnum, Metadata, OverlayOptions, PngOptions, Sharp, TiffOptions, TileOptions, WebpOptions } from "sharp";
|
|
5
5
|
/**
|
|
@@ -407,6 +407,17 @@ export interface ImgProcOpts {
|
|
|
407
407
|
* replacement IDs, e.g. allowing to override `name`, `date` etc.
|
|
408
408
|
*/
|
|
409
409
|
pathParts: Record<string, Fn3<ImgProcCtx, OutputSpec, BufferLike, string> | string>;
|
|
410
|
+
/**
|
|
411
|
+
* User provided environment, i.e. an object to provide arbitrary values to
|
|
412
|
+
* {@link Processor}s and for them to store results in.
|
|
413
|
+
*
|
|
414
|
+
* @remarks
|
|
415
|
+
* Note: This option is optional. Processors should only access the
|
|
416
|
+
* environment via {@link ImgProcCtx.env} which ensures the object is
|
|
417
|
+
* defined and it is only that version which will also be returned as part
|
|
418
|
+
* of the results from {@link processImage}...
|
|
419
|
+
*/
|
|
420
|
+
env?: IObjectOf<any>;
|
|
410
421
|
}
|
|
411
422
|
export interface ImgProcCtx {
|
|
412
423
|
path?: string;
|
|
@@ -421,6 +432,10 @@ export interface ImgProcCtx {
|
|
|
421
432
|
* {@link output}.
|
|
422
433
|
*/
|
|
423
434
|
outputs: Record<string, string>;
|
|
435
|
+
/**
|
|
436
|
+
* See {@link ImgProcOpts.env} for details/comments.
|
|
437
|
+
*/
|
|
438
|
+
env: IObjectOf<any>;
|
|
424
439
|
}
|
|
425
440
|
export declare const GRAVITY_POSITION: Record<Gravity, string>;
|
|
426
441
|
export declare const GRAVITY_MAP: Record<Gravity, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/imago",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "JSON & API-based declarative and extensible image processing trees/pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -32,26 +32,27 @@
|
|
|
32
32
|
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
33
33
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
34
34
|
"pub": "yarn npm publish --access public",
|
|
35
|
-
"test": "bun test"
|
|
35
|
+
"test": "bun test",
|
|
36
|
+
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/associative": "^6.3.
|
|
40
|
-
"@thi.ng/blurhash": "^0.1.
|
|
41
|
-
"@thi.ng/checks": "^3.5.
|
|
42
|
-
"@thi.ng/date": "^2.7.
|
|
43
|
-
"@thi.ng/defmulti": "^3.0.
|
|
44
|
-
"@thi.ng/errors": "^2.4.
|
|
45
|
-
"@thi.ng/file-io": "^1.3.
|
|
46
|
-
"@thi.ng/logger": "^3.0.
|
|
47
|
-
"@thi.ng/pixel": "^6.1.
|
|
48
|
-
"@thi.ng/pixel-dither": "^1.1.
|
|
49
|
-
"@thi.ng/prefixes": "^2.3.
|
|
39
|
+
"@thi.ng/api": "^8.9.28",
|
|
40
|
+
"@thi.ng/associative": "^6.3.46",
|
|
41
|
+
"@thi.ng/blurhash": "^0.1.13",
|
|
42
|
+
"@thi.ng/checks": "^3.5.2",
|
|
43
|
+
"@thi.ng/date": "^2.7.5",
|
|
44
|
+
"@thi.ng/defmulti": "^3.0.29",
|
|
45
|
+
"@thi.ng/errors": "^2.4.20",
|
|
46
|
+
"@thi.ng/file-io": "^1.3.6",
|
|
47
|
+
"@thi.ng/logger": "^3.0.5",
|
|
48
|
+
"@thi.ng/pixel": "^6.1.16",
|
|
49
|
+
"@thi.ng/pixel-dither": "^1.1.114",
|
|
50
|
+
"@thi.ng/prefixes": "^2.3.12",
|
|
50
51
|
"sharp": "^0.33.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@microsoft/api-extractor": "^7.40.1",
|
|
54
|
-
"@thi.ng/vectors": "^7.10.
|
|
55
|
+
"@thi.ng/vectors": "^7.10.16",
|
|
55
56
|
"esbuild": "^0.20.0",
|
|
56
57
|
"rimraf": "^5.0.5",
|
|
57
58
|
"typedoc": "^0.25.7",
|
|
@@ -180,5 +181,5 @@
|
|
|
180
181
|
"status": "alpha",
|
|
181
182
|
"year": 2024
|
|
182
183
|
},
|
|
183
|
-
"gitHead": "
|
|
184
|
+
"gitHead": "a421058a65ba76608d94129ac29451bfedaf201c\n"
|
|
184
185
|
}
|
package/proc.d.ts
CHANGED
|
@@ -4,12 +4,14 @@ export declare const LOGGER: import("@thi.ng/logger").ProxyLogger;
|
|
|
4
4
|
/**
|
|
5
5
|
* Main API function. Takes an image input (file path, buffer or existing Sharp
|
|
6
6
|
* instance) and applies given processing pipeline specs in sequence. Returns a
|
|
7
|
-
* promise of final processed image, input metadata (if any)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* promise of final processed image, input metadata (if any), an environment
|
|
8
|
+
* object of arbitrary data (likely produced by custom ops/processors) and an
|
|
9
|
+
* object of all written output paths (keyed by each output's
|
|
10
|
+
* {@link OutputSpec.id}). The process pipeline can be additionally configured
|
|
11
|
+
* via provided options.
|
|
10
12
|
*
|
|
11
13
|
* @remarks
|
|
12
|
-
* The `parentCtx` arg is internal use only!
|
|
14
|
+
* The `parentCtx` arg is internal use only (nested processors)!
|
|
13
15
|
*
|
|
14
16
|
* @param src
|
|
15
17
|
* @param specs
|
|
@@ -19,6 +21,7 @@ export declare const LOGGER: import("@thi.ng/logger").ProxyLogger;
|
|
|
19
21
|
export declare const processImage: (src: string | BufferLike | ArrayBuffer | Sharp, specs: ProcSpec[], opts?: Partial<ImgProcOpts>, parentCtx?: ImgProcCtx) => Promise<{
|
|
20
22
|
img: sharp.Sharp;
|
|
21
23
|
meta: sharp.Metadata;
|
|
24
|
+
env: import("@thi.ng/api").IObjectOf<any>;
|
|
22
25
|
outputs: Record<string, string>;
|
|
23
26
|
}>;
|
|
24
27
|
/**
|
package/proc.js
CHANGED
|
@@ -25,6 +25,7 @@ const processImage = async (src, specs, opts = {}, parentCtx) => {
|
|
|
25
25
|
const ctx = {
|
|
26
26
|
path: isString(src) ? src : parentCtx?.path,
|
|
27
27
|
outputs: parentCtx ? parentCtx.outputs : {},
|
|
28
|
+
env: parentCtx ? parentCtx.env : opts.env || {},
|
|
28
29
|
logger: opts.logger || LOGGER,
|
|
29
30
|
size: [meta.width, meta.height],
|
|
30
31
|
exif: parentCtx ? structuredClone(parentCtx.exif) : {},
|
|
@@ -59,7 +60,7 @@ const processImage = async (src, specs, opts = {}, parentCtx) => {
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
return { img, meta, outputs: ctx.outputs };
|
|
63
|
+
return { img, meta, env: ctx.env, outputs: ctx.outputs };
|
|
63
64
|
} finally {
|
|
64
65
|
if (ctx.iccFile)
|
|
65
66
|
deleteFile(ctx.iccFile, ctx.logger);
|