@thi.ng/imago 1.2.4 → 1.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 +7 -1
- package/README.md +1 -1
- package/api.d.ts +13 -0
- package/ops/output.d.ts +1 -0
- package/ops/output.js +9 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-07-
|
|
3
|
+
- **Last updated**: 2025-07-21T15:28:55Z
|
|
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,12 @@ 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
|
+
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@1.3.0) (2025-07-21)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- add `dataURL` output option ([eca0ee3](https://github.com/thi-ng/umbrella/commit/eca0ee3))
|
|
19
|
+
|
|
14
20
|
### [1.2.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@1.2.1) (2025-07-14)
|
|
15
21
|
|
|
16
22
|
#### 🩹 Bug fixes
|
package/README.md
CHANGED
package/api.d.ts
CHANGED
|
@@ -372,6 +372,19 @@ export interface OutputSpec extends ProcSpec {
|
|
|
372
372
|
* WebP output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#webp)
|
|
373
373
|
*/
|
|
374
374
|
webp?: WebpOptions;
|
|
375
|
+
/**
|
|
376
|
+
* Only used if {@link OutputSpec.path} is NOT set. If true, output will be
|
|
377
|
+
* captured as data URL, otherwise as binary data/buffer.
|
|
378
|
+
*
|
|
379
|
+
* @remarks
|
|
380
|
+
* Other conditions:
|
|
381
|
+
*
|
|
382
|
+
* - Requires {@link OutputSpec.format} to be set to a data URL compatible
|
|
383
|
+
* image format.
|
|
384
|
+
* - An error will be thrown during processing if the encoded image size
|
|
385
|
+
* exceeds 32KB.
|
|
386
|
+
*/
|
|
387
|
+
dataURL?: boolean;
|
|
375
388
|
}
|
|
376
389
|
export interface ResizeSpec extends ProcSpec {
|
|
377
390
|
op: "resize";
|
package/ops/output.d.ts
CHANGED
package/ops/output.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { encode } from "@thi.ng/blurhash";
|
|
2
2
|
import { isNumber, isPlainObject } from "@thi.ng/checks";
|
|
3
|
+
import { illegalArgs } from "@thi.ng/errors";
|
|
3
4
|
import { writeFile, writeJSON } from "@thi.ng/file-io";
|
|
4
|
-
import { firstNonNullKey } from "@thi.ng/object-utils
|
|
5
|
+
import { firstNonNullKey } from "@thi.ng/object-utils";
|
|
5
6
|
import { join, resolve } from "node:path";
|
|
6
7
|
import { formatPath } from "../path.js";
|
|
7
8
|
const outputProc = async (spec, input, ctx) => {
|
|
@@ -79,7 +80,7 @@ const outputProc = async (spec, input, ctx) => {
|
|
|
79
80
|
writeFile(path, result, null, ctx.logger);
|
|
80
81
|
ctx.outputs[opts.id] = path;
|
|
81
82
|
} else {
|
|
82
|
-
ctx.outputs[opts.id] = result;
|
|
83
|
+
ctx.outputs[opts.id] = format && opts.dataURL ? asDataURL(`image/${format}`, result) : result;
|
|
83
84
|
}
|
|
84
85
|
return [input, false];
|
|
85
86
|
};
|
|
@@ -122,6 +123,12 @@ const __outputBlurHash = async (opts, output, ctx) => {
|
|
|
122
123
|
ctx.logger.debug("computed blurhash:", hash);
|
|
123
124
|
ctx.outputs[opts.id] = hash;
|
|
124
125
|
};
|
|
126
|
+
const asDataURL = (mime, data) => {
|
|
127
|
+
if (data.length > 32768)
|
|
128
|
+
illegalArgs("encoded image too large for dataURL (max. 32KB allowed)");
|
|
129
|
+
return `data:${mime};base64,${data.toString("base64")}`;
|
|
130
|
+
};
|
|
125
131
|
export {
|
|
132
|
+
asDataURL,
|
|
126
133
|
outputProc
|
|
127
134
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/imago",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "JSON & API-based declarative and extensible image processing trees/pipelines",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -189,5 +189,5 @@
|
|
|
189
189
|
"status": "alpha",
|
|
190
190
|
"year": 2024
|
|
191
191
|
},
|
|
192
|
-
"gitHead": "
|
|
192
|
+
"gitHead": "0c467cd5bdf66531dc159e226d10cb6718426cc1\n"
|
|
193
193
|
}
|