@thi.ng/imago 0.7.9 → 0.8.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 +11 -1
- package/README.md +5 -2
- package/api.d.ts +7 -2
- package/ops/output.js +25 -17
- package/package.json +18 -18
- package/proc.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-07-06T12:02:19Z
|
|
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,16 @@ 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.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.8.0) (2024-07-06)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- make output path optional, record img buffer ([90258b2](https://github.com/thi-ng/umbrella/commit/90258b2))
|
|
17
|
+
- update OutputSpec.path handling
|
|
18
|
+
- if no path given, record encoded img buffer itself in outputs
|
|
19
|
+
- update outputProc() & __outputRaw()
|
|
20
|
+
- update docs
|
|
21
|
+
|
|
12
22
|
### [0.7.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.7.8) (2024-06-21)
|
|
13
23
|
|
|
14
24
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 188 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
|
>
|
|
@@ -258,6 +258,9 @@ Alternatively, a
|
|
|
258
258
|
the image can be computed and stored in the outputs. In this case, no file will
|
|
259
259
|
be written.
|
|
260
260
|
|
|
261
|
+
For all other formats, if no output path is provided in the spec, no file will
|
|
262
|
+
be written, but the encoded image buffer itself will be recorded in the outputs.
|
|
263
|
+
|
|
261
264
|
#### Templated output paths
|
|
262
265
|
|
|
263
266
|
Output paths can contain `{id}`-templated parts which will be replaced/expanded.
|
|
@@ -357,7 +360,7 @@ For Node.js REPL:
|
|
|
357
360
|
const imago = await import("@thi.ng/imago");
|
|
358
361
|
```
|
|
359
362
|
|
|
360
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 4.
|
|
363
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 4.95 KB
|
|
361
364
|
|
|
362
365
|
## Dependencies
|
|
363
366
|
|
package/api.d.ts
CHANGED
|
@@ -289,7 +289,12 @@ export interface OutputSpec extends ProcSpec {
|
|
|
289
289
|
id: string;
|
|
290
290
|
/**
|
|
291
291
|
* Possibly templated output path. See {@link formatPath} for details.
|
|
292
|
-
* Ignored if {@link OutputSpec.blurhash} is being used
|
|
292
|
+
* Ignored if {@link OutputSpec.blurhash} is being used.
|
|
293
|
+
*
|
|
294
|
+
* Otherwise, if given, the image will be written to the result path and the
|
|
295
|
+
* path stored in the `outputs` object returned by {@link processImage}. If
|
|
296
|
+
* no path is given, no file will be written and the encoded image buffer
|
|
297
|
+
* itself will be recorded in `outputs`.
|
|
293
298
|
*/
|
|
294
299
|
path?: string;
|
|
295
300
|
/**
|
|
@@ -447,7 +452,7 @@ export interface ImgProcCtx {
|
|
|
447
452
|
* Paths of all exported images, keyed by IDs given via {@link OutputSpec} /
|
|
448
453
|
* {@link output}.
|
|
449
454
|
*/
|
|
450
|
-
outputs: Record<string, string>;
|
|
455
|
+
outputs: Record<string, string | Buffer>;
|
|
451
456
|
/**
|
|
452
457
|
* See {@link ImgProcOpts.env} for details/comments.
|
|
453
458
|
*/
|
package/ops/output.js
CHANGED
|
@@ -61,29 +61,37 @@ const outputProc = async (spec, input, ctx) => {
|
|
|
61
61
|
if (opts.tile) output = output.tile(opts.tile);
|
|
62
62
|
if (format) output = output.toFormat(format);
|
|
63
63
|
const result = await output.toBuffer();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
if (opts.path !== void 0) {
|
|
65
|
+
const path = join(
|
|
66
|
+
outDir,
|
|
67
|
+
formatPath(opts.path, ctx, spec, result)
|
|
68
|
+
);
|
|
69
|
+
writeFile(path, result, null, ctx.logger);
|
|
70
|
+
ctx.outputs[opts.id] = path;
|
|
71
|
+
} else {
|
|
72
|
+
ctx.outputs[opts.id] = result;
|
|
73
|
+
}
|
|
70
74
|
return [input, false];
|
|
71
75
|
};
|
|
72
76
|
const __outputRaw = async (opts, output, ctx, outDir) => {
|
|
73
77
|
const { alpha = false, meta = false } = isPlainObject(opts.raw) ? opts.raw : {};
|
|
74
78
|
if (alpha) output = output.ensureAlpha();
|
|
75
79
|
const { data, info } = await output.raw().toBuffer({ resolveWithObject: true });
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
if (opts.path !== void 0) {
|
|
81
|
+
const path = join(outDir, formatPath(opts.path, ctx, opts, data));
|
|
82
|
+
writeFile(path, data, null, ctx.logger);
|
|
83
|
+
ctx.outputs[opts.id] = path;
|
|
84
|
+
if (meta) {
|
|
85
|
+
writeJSON(
|
|
86
|
+
path + ".meta.json",
|
|
87
|
+
{ ...info, exif: ctx.exif },
|
|
88
|
+
void 0,
|
|
89
|
+
void 0,
|
|
90
|
+
ctx.logger
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
ctx.outputs[opts.id] = data;
|
|
87
95
|
}
|
|
88
96
|
};
|
|
89
97
|
const __outputBlurHash = async (opts, output, ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/imago",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "JSON & API-based declarative and extensible image processing trees/pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,26 +36,26 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/associative": "^6.3.
|
|
41
|
-
"@thi.ng/blurhash": "^0.1.
|
|
42
|
-
"@thi.ng/checks": "^3.6.
|
|
43
|
-
"@thi.ng/date": "^2.7.
|
|
44
|
-
"@thi.ng/defmulti": "^3.0.
|
|
45
|
-
"@thi.ng/errors": "^2.5.
|
|
46
|
-
"@thi.ng/file-io": "^2.1.
|
|
47
|
-
"@thi.ng/logger": "^3.0.
|
|
48
|
-
"@thi.ng/pixel": "^6.1.
|
|
49
|
-
"@thi.ng/pixel-dither": "^1.1.
|
|
50
|
-
"@thi.ng/prefixes": "^2.3.
|
|
39
|
+
"@thi.ng/api": "^8.11.5",
|
|
40
|
+
"@thi.ng/associative": "^6.3.63",
|
|
41
|
+
"@thi.ng/blurhash": "^0.1.27",
|
|
42
|
+
"@thi.ng/checks": "^3.6.7",
|
|
43
|
+
"@thi.ng/date": "^2.7.21",
|
|
44
|
+
"@thi.ng/defmulti": "^3.0.42",
|
|
45
|
+
"@thi.ng/errors": "^2.5.10",
|
|
46
|
+
"@thi.ng/file-io": "^2.1.5",
|
|
47
|
+
"@thi.ng/logger": "^3.0.15",
|
|
48
|
+
"@thi.ng/pixel": "^6.1.35",
|
|
49
|
+
"@thi.ng/pixel-dither": "^1.1.133",
|
|
50
|
+
"@thi.ng/prefixes": "^2.3.22",
|
|
51
51
|
"sharp": "^0.33.4"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@microsoft/api-extractor": "^7.47.0",
|
|
55
|
-
"@thi.ng/vectors": "^7.11.
|
|
56
|
-
"esbuild": "^0.
|
|
57
|
-
"typedoc": "^0.
|
|
58
|
-
"typescript": "^5.5.
|
|
55
|
+
"@thi.ng/vectors": "^7.11.2",
|
|
56
|
+
"esbuild": "^0.23.0",
|
|
57
|
+
"typedoc": "^0.26.3",
|
|
58
|
+
"typescript": "^5.5.3"
|
|
59
59
|
},
|
|
60
60
|
"keywords": [
|
|
61
61
|
"avif",
|
|
@@ -185,5 +185,5 @@
|
|
|
185
185
|
"status": "alpha",
|
|
186
186
|
"year": 2024
|
|
187
187
|
},
|
|
188
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "70f493d9ccc97c5df5dda7e808e96cd1691097fc\n"
|
|
189
189
|
}
|
package/proc.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare const processImage: (src: string | BufferLike | ArrayBuffer | Sha
|
|
|
22
22
|
img: sharp.Sharp;
|
|
23
23
|
meta: sharp.Metadata;
|
|
24
24
|
env: import("@thi.ng/api").IObjectOf<any>;
|
|
25
|
-
outputs: Record<string, string>;
|
|
25
|
+
outputs: Record<string, string | Buffer>;
|
|
26
26
|
}>;
|
|
27
27
|
/**
|
|
28
28
|
* Extensible polymorphic function performing a single image processing step.
|