@thi.ng/imago 0.4.0 → 0.4.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-02-27T20:35:06Z
3
+ - **Last updated**: 2024-02-28T14:23:30Z
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.4.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.4.1) (2024-02-28)
13
+
14
+ #### 🩹 Bug fixes
15
+
16
+ - fix typedarray input handling in processImage() ([075ecaa](https://github.com/thi-ng/umbrella/commit/075ecaa))
17
+
12
18
  ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/imago@0.4.0) (2024-02-27)
13
19
 
14
20
  #### 🚀 Features
package/README.md CHANGED
@@ -309,7 +309,7 @@ For Node.js REPL:
309
309
  const imago = await import("@thi.ng/imago");
310
310
  ```
311
311
 
312
- Package sizes (brotli'd, pre-treeshake): ESM: 4.16 KB
312
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.15 KB
313
313
 
314
314
  ## Dependencies
315
315
 
package/api.d.ts CHANGED
@@ -126,9 +126,22 @@ export interface OutputSpec extends ProcSpec {
126
126
  id: string;
127
127
  /**
128
128
  * Possibly templated output path. See {@link formatPath} for details.
129
+ * Ignored if {@link OutputSpec.blurhash} is being used.
129
130
  */
130
131
  path: string;
132
+ /**
133
+ * AVIF output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#avif)
134
+ */
131
135
  avif?: AvifOptions;
136
+ /**
137
+ * If given, ONLY the blurhash of the image will be computed and stored in
138
+ * the `outputs` object returned by {@link processImage}. The
139
+ * {@link OutputSpec.path} will be ignored and no file will be written.
140
+ *
141
+ * @remarks
142
+ * Important: Ensure the image has already been downsized to ~50-500 pixels.
143
+ * Larger images are causing unnecessary & long processing...
144
+ */
132
145
  blurhash?: {
133
146
  /**
134
147
  * Blurhash detail setting in 1-9 range, possibly given separately for
@@ -138,11 +151,29 @@ export interface OutputSpec extends ProcSpec {
138
151
  */
139
152
  detail?: number | [number, number];
140
153
  };
154
+ /**
155
+ * GIF output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#gif)
156
+ */
141
157
  gif?: GifOptions;
158
+ /**
159
+ * JPEG 2000 output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#jp2)
160
+ */
142
161
  jp2?: Jp2Options;
162
+ /**
163
+ * JPEG output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#jpeg)
164
+ */
143
165
  jpeg?: JpegOptions;
166
+ /**
167
+ * JPEG XL output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#jxl)
168
+ */
144
169
  jxl?: JxlOptions;
170
+ /**
171
+ * PNG output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#avif)
172
+ */
145
173
  png?: PngOptions;
174
+ /**
175
+ * Raw binary output options.
176
+ */
146
177
  raw?: boolean | {
147
178
  /**
148
179
  * If true, ensures the buffer has an alpha channel
@@ -154,8 +185,17 @@ export interface OutputSpec extends ProcSpec {
154
185
  */
155
186
  meta?: boolean;
156
187
  };
188
+ /**
189
+ * Tiled format output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#tile)
190
+ */
157
191
  tile?: TileOptions;
192
+ /**
193
+ * TIFF output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#tiff)
194
+ */
158
195
  tiff?: TiffOptions;
196
+ /**
197
+ * WebP output options. See [Sharp docs](https://sharp.pixelplumbing.com/api-output#webp)
198
+ */
159
199
  webp?: WebpOptions;
160
200
  }
161
201
  export interface ResizeSpec extends ProcSpec {
package/ops/output.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { encode } from "@thi.ng/blurhash";
2
+ import { isNumber, isPlainObject } from "@thi.ng/checks";
2
3
  import { writeFile, writeJSON } from "@thi.ng/file-io";
3
4
  import { join, resolve } from "node:path";
4
5
  import { formatPath } from "../path.js";
5
- import { isNumber, isPlainObject } from "@thi.ng/checks";
6
6
  const outputProc = async (spec, input, ctx) => {
7
7
  const opts = spec;
8
8
  const outDir = resolve(ctx.opts.outDir || ".");
@@ -106,8 +106,8 @@ const outputBlurHash = async (opts, output, ctx) => {
106
106
  dx,
107
107
  dy
108
108
  );
109
- ctx.outputs[opts.id] = hash;
110
109
  ctx.logger.debug("computed blurhash:", hash);
110
+ ctx.outputs[opts.id] = hash;
111
111
  };
112
112
  export {
113
113
  outputProc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/imago",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "JSON & API-based declarative and extensible image processing trees/pipelines",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,19 +39,19 @@
39
39
  "@thi.ng/associative": "^6.3.43",
40
40
  "@thi.ng/blurhash": "^0.1.11",
41
41
  "@thi.ng/checks": "^3.5.0",
42
- "@thi.ng/date": "^2.7.1",
42
+ "@thi.ng/date": "^2.7.2",
43
43
  "@thi.ng/defmulti": "^3.0.26",
44
44
  "@thi.ng/errors": "^2.4.18",
45
45
  "@thi.ng/file-io": "^1.3.4",
46
46
  "@thi.ng/logger": "^3.0.3",
47
- "@thi.ng/pixel": "^6.1.12",
48
- "@thi.ng/pixel-dither": "^1.1.110",
47
+ "@thi.ng/pixel": "^6.1.13",
48
+ "@thi.ng/pixel-dither": "^1.1.111",
49
49
  "@thi.ng/prefixes": "^2.3.10",
50
50
  "sharp": "^0.33.2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@microsoft/api-extractor": "^7.40.1",
54
- "@thi.ng/vectors": "^7.10.12",
54
+ "@thi.ng/vectors": "^7.10.13",
55
55
  "esbuild": "^0.20.0",
56
56
  "rimraf": "^5.0.5",
57
57
  "typedoc": "^0.25.7",
@@ -126,5 +126,5 @@
126
126
  "status": "alpha",
127
127
  "year": 2024
128
128
  },
129
- "gitHead": "41860743a21093aa13b6b7f4e36cd5e2e934d159\n"
129
+ "gitHead": "190d68e7f7524631b333cfdbf32c6a23be27c166\n"
130
130
  }
package/proc.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import type { TypedArray } from "@thi.ng/api";
2
3
  import sharp, { type Sharp } from "sharp";
3
4
  import type { ImgProcCtx, ImgProcOpts, ProcSpec } from "./api.js";
4
5
  export declare const LOGGER: import("@thi.ng/logger").ProxyLogger;
@@ -17,7 +18,7 @@ export declare const LOGGER: import("@thi.ng/logger").ProxyLogger;
17
18
  * @param opts
18
19
  * @param parentCtx
19
20
  */
20
- export declare const processImage: (src: string | Buffer | Sharp, specs: ProcSpec[], opts?: Partial<ImgProcOpts>, parentCtx?: ImgProcCtx) => Promise<{
21
+ export declare const processImage: (src: string | TypedArray | Buffer | ArrayBuffer | Sharp, specs: ProcSpec[], opts?: Partial<ImgProcOpts>, parentCtx?: ImgProcCtx) => Promise<{
21
22
  img: sharp.Sharp;
22
23
  meta: sharp.Metadata;
23
24
  outputs: Record<string, string>;
package/proc.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { isArrayBufferView, isString } from "@thi.ng/checks";
2
2
  import { defmulti } from "@thi.ng/defmulti";
3
+ import { createTempFile, deleteFile } from "@thi.ng/file-io";
3
4
  import { ROOT } from "@thi.ng/logger";
4
5
  import sharp, {} from "sharp";
5
6
  import { blurProc } from "./ops/blur.js";
@@ -16,10 +17,9 @@ import { outputProc } from "./ops/output.js";
16
17
  import { resizeProc } from "./ops/resize.js";
17
18
  import { rotateProc } from "./ops/rotate.js";
18
19
  import { ensureSize } from "./units.js";
19
- import { createTempFile, deleteFile } from "@thi.ng/file-io";
20
20
  const LOGGER = ROOT.childLogger("imgproc");
21
21
  const processImage = async (src, specs, opts = {}, parentCtx) => {
22
- let img = isString(src) || isArrayBufferView(src.buffer) ? sharp(src) : src;
22
+ let img = isString(src) || isArrayBufferView(src) ? sharp(src) : src;
23
23
  const meta = await img.metadata();
24
24
  ensureSize(meta);
25
25
  const ctx = {