@workglow/tasks 0.2.20 → 0.2.22

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/dist/node.js CHANGED
@@ -4,8 +4,8 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
  // src/task/image/registerImageRasterCodec.node.ts
5
5
  import { registerImageRasterCodec } from "@workglow/util/media";
6
6
 
7
- // src/task/image/imageRasterCodecNode.ts
8
- import { parseDataUri } from "@workglow/util/media";
7
+ // src/task/image/imageRasterCodec.server.ts
8
+ import { decodeBufferToRaw, encodeRawPixels } from "@workglow/util/media";
9
9
 
10
10
  // src/task/image/imageCodecLimits.ts
11
11
  var MAX_DECODED_PIXELS = 1e8;
@@ -69,7 +69,13 @@ function normalizeOutputMimeType(mimeType) {
69
69
  throw new Error(`Image raster codec: unsupported output mime type "${mimeType}". ` + `Supported: ${SUPPORTED_OUTPUT_MIME_TYPES.join(", ")}.`);
70
70
  }
71
71
 
72
- // src/task/image/imageRasterCodecNode.ts
72
+ // src/task/image/imageRasterCodec.server.ts
73
+ function parseDataUri(dataUri) {
74
+ const match = dataUri.match(/^data:([^;]+);base64,(.+)$/);
75
+ if (!match)
76
+ throw new Error("Invalid base64 data URI");
77
+ return { mimeType: match[1], base64: match[2] };
78
+ }
73
79
  function expandGrayAlphaToRgba(src, width, height) {
74
80
  const n = width * height;
75
81
  const dst = new Uint8ClampedArray(n * 4);
@@ -83,35 +89,20 @@ function expandGrayAlphaToRgba(src, width, height) {
83
89
  }
84
90
  return dst;
85
91
  }
86
- var _sharp;
87
- async function getSharp() {
88
- if (!_sharp) {
89
- try {
90
- _sharp = (await import("sharp")).default;
91
- } catch {
92
- throw new Error("The Node/Bun image raster codec requires the optional 'sharp' package. Install it with: npm install sharp (or bun add sharp)");
93
- }
94
- }
95
- return _sharp;
96
- }
97
92
  async function decodeDataUri(dataUri) {
98
93
  assertIsDataUri(dataUri);
99
94
  const declaredMime = extractDataUriMimeType(dataUri);
100
95
  if (declaredMime && REJECTED_DECODE_MIME_TYPES.has(declaredMime)) {
101
- throw new Error(`Image raster codec: refusing to rasterize "${declaredMime}". Vector and animated formats lose information when converted to pixels. Convert to PNG, JPEG, or WebP before passing to the codec.`);
96
+ throw new Error(`Image raster codec: refusing to rasterize "${declaredMime}". ` + `Vector and animated formats lose information when converted to pixels. ` + `Convert to PNG, JPEG, or WebP before passing to the codec.`);
102
97
  }
103
- const sharp = await getSharp();
104
98
  const { base64 } = parseDataUri(dataUri);
105
99
  const estimatedBytes = Math.ceil(base64.length * 3 / 4);
106
100
  assertWithinByteBudget(estimatedBytes, MAX_INPUT_BYTES_NODE);
107
101
  const buffer = Buffer.from(base64, "base64");
108
- const { data, info } = await sharp(buffer, {
102
+ const { data, width, height, channels: ch } = await decodeBufferToRaw(buffer, {
109
103
  limitInputPixels: MAX_DECODED_PIXELS,
110
104
  sequentialRead: true
111
- }).raw().toBuffer({ resolveWithObject: true });
112
- const width = info.width;
113
- const height = info.height;
114
- const ch = info.channels;
105
+ });
115
106
  assertWithinPixelBudget(width, height);
116
107
  if (ch === 2) {
117
108
  return {
@@ -132,11 +123,9 @@ async function decodeDataUri(dataUri) {
132
123
  throw new Error(`Unsupported decoded channel count: ${ch}`);
133
124
  }
134
125
  async function encodeDataUri(image, mimeType) {
135
- const sharp = await getSharp();
136
126
  const { data, width, height, channels } = image;
137
127
  const fmt = normalizeOutputMimeType(mimeType);
138
- const base = sharp(Buffer.from(data), { raw: { width, height, channels } });
139
- const out = fmt === "image/jpeg" ? await base.jpeg({ quality: 92, mozjpeg: true }).toBuffer() : fmt === "image/webp" ? await base.webp({ quality: 92 }).toBuffer() : await base.png({ compressionLevel: 6 }).toBuffer();
128
+ const out = fmt === "image/jpeg" ? await encodeRawPixels({ data, width, height, channels }, { format: "jpeg", quality: 92, mozjpeg: true }) : fmt === "image/webp" ? await encodeRawPixels({ data, width, height, channels }, { format: "webp", quality: 92 }) : await encodeRawPixels({ data, width, height, channels }, { format: "png", compressionLevel: 6 });
140
129
  return `data:${fmt};base64,${out.toString("base64")}`;
141
130
  }
142
131
  function createNodeImageRasterCodec() {
@@ -188,7 +177,7 @@ function cpuBoxBlur(bin, radius) {
188
177
  return { data: dst, width, height, channels };
189
178
  }
190
179
  registerFilterOp("cpu", "blur", (image, { radius }) => {
191
- return CpuImage.fromImageBinary(cpuBoxBlur(image.getBinary(), Math.max(1, radius | 0)));
180
+ return CpuImage.fromRaw(cpuBoxBlur(image.getBinary(), Math.max(1, radius | 0)));
192
181
  });
193
182
 
194
183
  // src/task/image/border/border.cpu.ts
@@ -224,7 +213,7 @@ function cpuBorder(bin, borderWidth, color) {
224
213
  return { data: dst, width: dstW, height: dstH, channels: outCh };
225
214
  }
226
215
  registerFilterOp2("cpu", "border", (image, { borderWidth, color }) => {
227
- return CpuImage2.fromImageBinary(cpuBorder(image.getBinary(), borderWidth, color));
216
+ return CpuImage2.fromRaw(cpuBorder(image.getBinary(), borderWidth, color));
228
217
  });
229
218
 
230
219
  // src/task/image/brightness/brightness.cpu.ts
@@ -247,7 +236,7 @@ function cpuBrightness(bin, amount) {
247
236
  return { data: dst, width, height, channels };
248
237
  }
249
238
  registerFilterOp3("cpu", "brightness", (image, { amount }) => {
250
- return CpuImage3.fromImageBinary(cpuBrightness(image.getBinary(), amount));
239
+ return CpuImage3.fromRaw(cpuBrightness(image.getBinary(), amount));
251
240
  });
252
241
 
253
242
  // src/task/image/contrast/contrast.cpu.ts
@@ -275,7 +264,7 @@ function cpuContrast(bin, amount) {
275
264
  return { data: dst, width, height, channels };
276
265
  }
277
266
  registerFilterOp4("cpu", "contrast", (image, { amount }) => {
278
- return CpuImage4.fromImageBinary(cpuContrast(image.getBinary(), amount));
267
+ return CpuImage4.fromRaw(cpuContrast(image.getBinary(), amount));
279
268
  });
280
269
 
281
270
  // src/task/image/crop/crop.cpu.ts
@@ -300,7 +289,7 @@ function cpuCrop(bin, left, top, width, height) {
300
289
  return { data: dst, width: w, height: h, channels };
301
290
  }
302
291
  registerFilterOp5("cpu", "crop", (image, { left, top, width, height }) => {
303
- return CpuImage5.fromImageBinary(cpuCrop(image.getBinary(), left, top, width, height));
292
+ return CpuImage5.fromRaw(cpuCrop(image.getBinary(), left, top, width, height));
304
293
  });
305
294
 
306
295
  // src/task/image/flip/flip.cpu.ts
@@ -329,7 +318,7 @@ function cpuFlip(bin, direction) {
329
318
  return { data: dst, width, height, channels };
330
319
  }
331
320
  registerFilterOp6("cpu", "flip", (image, { direction }) => {
332
- return CpuImage6.fromImageBinary(cpuFlip(image.getBinary(), direction));
321
+ return CpuImage6.fromRaw(cpuFlip(image.getBinary(), direction));
333
322
  });
334
323
 
335
324
  // src/task/image/grayscale/grayscale.cpu.ts
@@ -356,7 +345,7 @@ function cpuGrayscale(bin) {
356
345
  return { data: dst, width, height, channels: 4 };
357
346
  }
358
347
  registerFilterOp7("cpu", "grayscale", (image, _params) => {
359
- return CpuImage7.fromImageBinary(cpuGrayscale(image.getBinary()));
348
+ return CpuImage7.fromRaw(cpuGrayscale(image.getBinary()));
360
349
  });
361
350
 
362
351
  // src/task/image/invert/invert.cpu.ts
@@ -379,7 +368,7 @@ function cpuInvert(bin) {
379
368
  return { data: dst, width, height, channels };
380
369
  }
381
370
  registerFilterOp8("cpu", "invert", (image, _params) => {
382
- return CpuImage8.fromImageBinary(cpuInvert(image.getBinary()));
371
+ return CpuImage8.fromRaw(cpuInvert(image.getBinary()));
383
372
  });
384
373
 
385
374
  // src/task/image/pixelate/pixelate.cpu.ts
@@ -415,7 +404,7 @@ function cpuPixelate(bin, blockSize) {
415
404
  return { data: dst, width, height, channels };
416
405
  }
417
406
  registerFilterOp9("cpu", "pixelate", (image, { blockSize }) => {
418
- return CpuImage9.fromImageBinary(cpuPixelate(image.getBinary(), blockSize));
407
+ return CpuImage9.fromRaw(cpuPixelate(image.getBinary(), blockSize));
419
408
  });
420
409
 
421
410
  // src/task/image/posterize/posterize.cpu.ts
@@ -443,7 +432,7 @@ function cpuPosterize(bin, levels) {
443
432
  return { data: dst, width, height, channels };
444
433
  }
445
434
  registerFilterOp10("cpu", "posterize", (image, { levels }) => {
446
- return CpuImage10.fromImageBinary(cpuPosterize(image.getBinary(), levels));
435
+ return CpuImage10.fromRaw(cpuPosterize(image.getBinary(), levels));
447
436
  });
448
437
 
449
438
  // src/task/image/resize/resize.cpu.ts
@@ -465,7 +454,7 @@ function cpuResize(bin, dstW, dstH) {
465
454
  return { data: dst, width: dstW, height: dstH, channels };
466
455
  }
467
456
  registerFilterOp11("cpu", "resize", (image, { width, height }) => {
468
- return CpuImage11.fromImageBinary(cpuResize(image.getBinary(), width, height));
457
+ return CpuImage11.fromRaw(cpuResize(image.getBinary(), width, height));
469
458
  });
470
459
 
471
460
  // src/task/image/rotate/rotate.cpu.ts
@@ -499,7 +488,7 @@ function cpuRotate(bin, angle) {
499
488
  return { data: dst, width: dstW, height: dstH, channels };
500
489
  }
501
490
  registerFilterOp12("cpu", "rotate", (image, { angle }) => {
502
- return CpuImage12.fromImageBinary(cpuRotate(image.getBinary(), angle));
491
+ return CpuImage12.fromRaw(cpuRotate(image.getBinary(), angle));
503
492
  });
504
493
 
505
494
  // src/task/image/sepia/sepia.cpu.ts
@@ -528,7 +517,7 @@ function cpuSepia(bin) {
528
517
  return { data: dst, width, height, channels };
529
518
  }
530
519
  registerFilterOp13("cpu", "sepia", (image, _params) => {
531
- return CpuImage13.fromImageBinary(cpuSepia(image.getBinary()));
520
+ return CpuImage13.fromRaw(cpuSepia(image.getBinary()));
532
521
  });
533
522
 
534
523
  // src/task/image/threshold/threshold.cpu.ts
@@ -553,7 +542,7 @@ function cpuThreshold(bin, value) {
553
542
  return { data: dst, width, height, channels };
554
543
  }
555
544
  registerFilterOp14("cpu", "threshold", (image, { value }) => {
556
- return CpuImage14.fromImageBinary(cpuThreshold(image.getBinary(), value));
545
+ return CpuImage14.fromRaw(cpuThreshold(image.getBinary(), value));
557
546
  });
558
547
 
559
548
  // src/task/image/tint/tint.cpu.ts
@@ -593,7 +582,7 @@ function cpuTint(bin, tr, tg, tb, amount) {
593
582
  }
594
583
  registerFilterOp15("cpu", "tint", (image, { color, amount }) => {
595
584
  const { r: tr, g: tg, b: tb } = resolveColor2(color);
596
- return CpuImage15.fromImageBinary(cpuTint(image.getBinary(), tr, tg, tb, amount));
585
+ return CpuImage15.fromRaw(cpuTint(image.getBinary(), tr, tg, tb, amount));
597
586
  });
598
587
 
599
588
  // src/task/image/transparency/transparency.cpu.ts
@@ -615,7 +604,7 @@ function cpuTransparency(bin, amount) {
615
604
  return { data: dst, width, height, channels: 4 };
616
605
  }
617
606
  registerFilterOp16("cpu", "transparency", (image, { amount }) => {
618
- return CpuImage16.fromImageBinary(cpuTransparency(image.getBinary(), amount));
607
+ return CpuImage16.fromRaw(cpuTransparency(image.getBinary(), amount));
619
608
  });
620
609
 
621
610
  // src/task/image/blur/blur.sharp.ts
@@ -736,14 +725,32 @@ registerFilterOp29("sharp", "threshold", (image, { value }) => {
736
725
 
737
726
  // src/task/image/tint/tint.sharp.ts
738
727
  import { registerFilterOp as registerFilterOp30, resolveColor as resolveColor4 } from "@workglow/util/media";
739
- registerFilterOp30("sharp", "tint", (image, { color }) => {
728
+ registerFilterOp30("sharp", "tint", (image, { color, amount }) => {
740
729
  const { r, g, b } = resolveColor4(color);
741
- return image.apply((p) => p.tint({ r, g, b }));
730
+ const a = 1 - amount;
731
+ const offR = r * amount;
732
+ const offG = g * amount;
733
+ const offB = b * amount;
734
+ return image.apply((p) => p.linear([a, a, a], [offR, offG, offB]));
742
735
  });
743
736
 
744
737
  // src/codec.node.ts
745
- import { applyFilter, registerPreviewResizeFn } from "@workglow/util/media";
746
- registerPreviewResizeFn((image, width, height) => applyFilter(image, "resize", { width, height }));
738
+ import {
739
+ GpuImageFactory,
740
+ applyFilter,
741
+ registerPreviewResizeFn
742
+ } from "@workglow/util/media";
743
+ registerPreviewResizeFn(async (value, width, height) => {
744
+ const gpu = await GpuImageFactory.from(value);
745
+ try {
746
+ const out = applyFilter(gpu, "resize", { width, height });
747
+ gpu.dispose();
748
+ return await out.toImageValue(value.previewScale);
749
+ } catch (err) {
750
+ gpu.dispose();
751
+ throw err;
752
+ }
753
+ });
747
754
 
748
755
  // src/task/image/imageTextRender.ts
749
756
  import { createServiceToken, globalServiceRegistry } from "@workglow/util";
@@ -792,6 +799,7 @@ async function renderImageTextToRgba(params) {
792
799
  }
793
800
 
794
801
  // src/task/image/imageTextRender.server.ts
802
+ import { decodeBufferToRaw as decodeBufferToRaw2 } from "@workglow/util/media";
795
803
  function buildTextSvg(params) {
796
804
  const { width, height, text, font, fontSize, bold, italic, color, position } = params;
797
805
  const lines = escapeImageTextXmlText(text).split(`
@@ -820,25 +828,20 @@ function buildTextSvg(params) {
820
828
  function createServerImageTextRenderer() {
821
829
  return {
822
830
  async renderToRgba(params) {
823
- let sharp;
824
- try {
825
- sharp = (await import("sharp")).default;
826
- } catch {
827
- throw new Error("ImageTextTask: rendering text on this runtime requires the optional 'sharp' package (install with: bun add sharp)");
828
- }
829
831
  const svg = buildTextSvg(params);
830
832
  const buffer = Buffer.from(svg, "utf8");
831
- const { data, info } = await sharp(buffer, {
833
+ const { data, width, height, channels } = await decodeBufferToRaw2(buffer, {
832
834
  limitInputPixels: MAX_DECODED_PIXELS,
833
- sequentialRead: true
834
- }).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
835
- if (info.channels !== 4) {
836
- throw new Error(`ImageTextTask: expected RGBA from sharp, got ${info.channels} channels`);
835
+ sequentialRead: true,
836
+ ensureAlpha: true
837
+ });
838
+ if (channels !== 4) {
839
+ throw new Error(`ImageTextTask: expected RGBA from sharp, got ${channels} channels`);
837
840
  }
838
841
  return {
839
842
  data: new Uint8ClampedArray(data),
840
- width: info.width,
841
- height: info.height,
843
+ width,
844
+ height,
842
845
  channels: 4
843
846
  };
844
847
  }
@@ -6486,88 +6489,53 @@ import {
6486
6489
  } from "@workglow/util/media";
6487
6490
 
6488
6491
  // src/task/image/ImageFilterTask.ts
6489
- import {
6490
- Task as Task42
6491
- } from "@workglow/task-graph";
6492
- import {
6493
- applyFilter as applyFilter2,
6494
- CpuImage as CpuImage17,
6495
- GpuImageFactory,
6496
- getGpuImageFactory,
6497
- hasFilterOp,
6498
- previewSource
6499
- } from "@workglow/util/media";
6492
+ import { Task as Task42 } from "@workglow/task-graph";
6493
+ import { applyFilter as applyFilter2, CpuImage as CpuImage17, GpuImageFactory as GpuImageFactory2, hasFilterOp } from "@workglow/util/media";
6500
6494
 
6501
6495
  class ImageFilterTask extends Task42 {
6502
6496
  scalePreviewParams(params, _scale) {
6503
6497
  return params;
6504
6498
  }
6505
- async hydrateInput(image) {
6506
- if (image !== null && typeof image === "object" && "backend" in image && "retain" in image && "release" in image && "materialize" in image) {
6507
- return image;
6508
- }
6509
- if (typeof image === "string" && image.startsWith("data:")) {
6510
- return GpuImageFactory.fromDataUri(image);
6511
- }
6512
- if (typeof Blob !== "undefined" && image instanceof Blob) {
6513
- return GpuImageFactory.fromBlob(image);
6514
- }
6515
- if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
6516
- const fromImageBitmap = getGpuImageFactory("fromImageBitmap");
6517
- if (!fromImageBitmap) {
6518
- throw new Error("ImageFilterTask: received ImageBitmap but GpuImage.fromImageBitmap is not registered " + "in this runtime. ImageBitmap inputs require the browser entry point.");
6499
+ async runFilter(input) {
6500
+ const previewScale = input.image.previewScale;
6501
+ let gpu = await GpuImageFactory2.from(input.image);
6502
+ try {
6503
+ if (!hasFilterOp(gpu.backend, this.filterName)) {
6504
+ const cpu = await CpuImage17.from(input.image);
6505
+ gpu.dispose();
6506
+ gpu = cpu;
6519
6507
  }
6520
- return fromImageBitmap(image);
6521
- }
6522
- if (image !== null && typeof image === "object" && "data" in image && "width" in image && "height" in image && "channels" in image) {
6523
- const bin = image;
6524
- const asyncFactory = getGpuImageFactory("fromImageBinaryAsync");
6525
- if (asyncFactory)
6526
- return asyncFactory(bin);
6527
- return GpuImageFactory.fromImageBinary(bin);
6528
- }
6529
- const ctor = image && typeof image === "object" && image.constructor ? image.constructor.name : typeof image;
6530
- const keys = image && typeof image === "object" ? Object.keys(image).slice(0, 10).join(", ") : "";
6531
- throw new Error(`ImageFilterTask: input.image is not a recognized image shape (got ${ctor}` + (keys ? ` with keys [${keys}]` : "") + `). Expected one of: GpuImage instance, raw ImageBinary, Blob, ImageBitmap, ` + `or a data: URI string.`);
6532
- }
6533
- async execute(input, ctx) {
6534
- let inputImage = await this.hydrateInput(input.image);
6535
- if (!hasFilterOp(inputImage.backend, this.filterName)) {
6536
- const bin = await inputImage.materialize();
6537
- const cpu = CpuImage17.fromImageBinary(bin, inputImage.previewScale);
6538
- inputImage.release();
6539
- inputImage = cpu;
6540
- }
6541
- const params = this.scalePreviewParams(this.opParams(input), inputImage.previewScale);
6542
- const out = applyFilter2(inputImage, this.filterName, params);
6543
- inputImage.release();
6544
- ctx.resourceScope?.register(`gpuimage:${String(this.id)}:image`, async () => out.release());
6545
- return { image: out };
6508
+ const params = this.scalePreviewParams(this.opParams(input), previewScale);
6509
+ const out = applyFilter2(gpu, this.filterName, params);
6510
+ gpu.dispose();
6511
+ try {
6512
+ const value = await out.toImageValue(previewScale);
6513
+ return { image: value };
6514
+ } catch (err) {
6515
+ try {
6516
+ out.dispose();
6517
+ } catch {}
6518
+ throw err;
6519
+ }
6520
+ } catch (err) {
6521
+ gpu.dispose();
6522
+ throw err;
6523
+ }
6524
+ }
6525
+ async execute(input, _ctx) {
6526
+ return this.runFilter(input);
6546
6527
  }
6547
6528
  async executePreview(input, _ctx) {
6548
- const inputImage = await this.hydrateInput(input.image);
6549
- let sourced = previewSource(inputImage);
6550
- if (!hasFilterOp(sourced.backend, this.filterName)) {
6551
- const bin = await sourced.materialize();
6552
- const cpu = CpuImage17.fromImageBinary(bin, sourced.previewScale);
6553
- if (sourced !== inputImage)
6554
- sourced.release();
6555
- sourced = cpu;
6556
- }
6557
- const params = this.scalePreviewParams(this.opParams(input), sourced.previewScale);
6558
- const out = applyFilter2(sourced, this.filterName, params);
6559
- if (sourced !== inputImage)
6560
- sourced.release();
6561
- return { image: out };
6529
+ return this.runFilter(input);
6562
6530
  }
6563
6531
  }
6564
6532
  // src/task/image/blur/ImageBlurTask.ts
6565
6533
  import { CreateWorkflow as CreateWorkflow16, Workflow as Workflow17 } from "@workglow/task-graph";
6566
- import { GpuImageSchema } from "@workglow/util/media";
6534
+ import { ImageValueSchema } from "@workglow/util/media";
6567
6535
  var inputSchema41 = {
6568
6536
  type: "object",
6569
6537
  properties: {
6570
- image: GpuImageSchema({ title: "Image", description: "Source image" }),
6538
+ image: ImageValueSchema({ title: "Image", description: "Source image" }),
6571
6539
  radius: {
6572
6540
  type: "number",
6573
6541
  title: "Radius",
@@ -6582,7 +6550,7 @@ var inputSchema41 = {
6582
6550
  };
6583
6551
  var outputSchema40 = {
6584
6552
  type: "object",
6585
- properties: { image: GpuImageSchema({ title: "Image", description: "Blurred image" }) },
6553
+ properties: { image: ImageValueSchema({ title: "Image", description: "Blurred image" }) },
6586
6554
  required: ["image"],
6587
6555
  additionalProperties: false
6588
6556
  };
@@ -6609,11 +6577,11 @@ class ImageBlurTask extends ImageFilterTask {
6609
6577
  Workflow17.prototype.imageBlur = CreateWorkflow16(ImageBlurTask);
6610
6578
  // src/task/image/border/ImageBorderTask.ts
6611
6579
  import { CreateWorkflow as CreateWorkflow17, Workflow as Workflow18 } from "@workglow/task-graph";
6612
- import { GpuImageSchema as GpuImageSchema2 } from "@workglow/util/media";
6580
+ import { ImageValueSchema as ImageValueSchema2 } from "@workglow/util/media";
6613
6581
  var inputSchema42 = {
6614
6582
  type: "object",
6615
6583
  properties: {
6616
- image: GpuImageSchema2({ title: "Image", description: "Source image" }),
6584
+ image: ImageValueSchema2({ title: "Image", description: "Source image" }),
6617
6585
  borderWidth: {
6618
6586
  type: "integer",
6619
6587
  title: "Border Width",
@@ -6646,7 +6614,7 @@ var inputSchema42 = {
6646
6614
  };
6647
6615
  var outputSchema41 = {
6648
6616
  type: "object",
6649
- properties: { image: GpuImageSchema2({ title: "Image", description: "Image with border" }) },
6617
+ properties: { image: ImageValueSchema2({ title: "Image", description: "Image with border" }) },
6650
6618
  required: ["image"],
6651
6619
  additionalProperties: false
6652
6620
  };
@@ -6676,11 +6644,11 @@ class ImageBorderTask extends ImageFilterTask {
6676
6644
  Workflow18.prototype.imageBorder = CreateWorkflow17(ImageBorderTask);
6677
6645
  // src/task/image/brightness/ImageBrightnessTask.ts
6678
6646
  import { CreateWorkflow as CreateWorkflow18, Workflow as Workflow19 } from "@workglow/task-graph";
6679
- import { GpuImageSchema as GpuImageSchema3 } from "@workglow/util/media";
6647
+ import { ImageValueSchema as ImageValueSchema3 } from "@workglow/util/media";
6680
6648
  var inputSchema43 = {
6681
6649
  type: "object",
6682
6650
  properties: {
6683
- image: GpuImageSchema3({ title: "Image", description: "Source image" }),
6651
+ image: ImageValueSchema3({ title: "Image", description: "Source image" }),
6684
6652
  amount: {
6685
6653
  type: "number",
6686
6654
  title: "Amount",
@@ -6695,7 +6663,7 @@ var inputSchema43 = {
6695
6663
  };
6696
6664
  var outputSchema42 = {
6697
6665
  type: "object",
6698
- properties: { image: GpuImageSchema3({ title: "Image", description: "Brightness-adjusted image" }) },
6666
+ properties: { image: ImageValueSchema3({ title: "Image", description: "Brightness-adjusted image" }) },
6699
6667
  required: ["image"],
6700
6668
  additionalProperties: false
6701
6669
  };
@@ -6719,11 +6687,11 @@ class ImageBrightnessTask extends ImageFilterTask {
6719
6687
  Workflow19.prototype.imageBrightness = CreateWorkflow18(ImageBrightnessTask);
6720
6688
  // src/task/image/contrast/ImageContrastTask.ts
6721
6689
  import { CreateWorkflow as CreateWorkflow19, Workflow as Workflow20 } from "@workglow/task-graph";
6722
- import { GpuImageSchema as GpuImageSchema4 } from "@workglow/util/media";
6690
+ import { ImageValueSchema as ImageValueSchema4 } from "@workglow/util/media";
6723
6691
  var inputSchema44 = {
6724
6692
  type: "object",
6725
6693
  properties: {
6726
- image: GpuImageSchema4({ title: "Image", description: "Source image" }),
6694
+ image: ImageValueSchema4({ title: "Image", description: "Source image" }),
6727
6695
  amount: {
6728
6696
  type: "number",
6729
6697
  title: "Amount",
@@ -6738,7 +6706,7 @@ var inputSchema44 = {
6738
6706
  };
6739
6707
  var outputSchema43 = {
6740
6708
  type: "object",
6741
- properties: { image: GpuImageSchema4({ title: "Image", description: "Contrast-adjusted image" }) },
6709
+ properties: { image: ImageValueSchema4({ title: "Image", description: "Contrast-adjusted image" }) },
6742
6710
  required: ["image"],
6743
6711
  additionalProperties: false
6744
6712
  };
@@ -6762,11 +6730,11 @@ class ImageContrastTask extends ImageFilterTask {
6762
6730
  Workflow20.prototype.imageContrast = CreateWorkflow19(ImageContrastTask);
6763
6731
  // src/task/image/crop/ImageCropTask.ts
6764
6732
  import { CreateWorkflow as CreateWorkflow20, Workflow as Workflow21 } from "@workglow/task-graph";
6765
- import { GpuImageSchema as GpuImageSchema5 } from "@workglow/util/media";
6733
+ import { ImageValueSchema as ImageValueSchema5 } from "@workglow/util/media";
6766
6734
  var inputSchema45 = {
6767
6735
  type: "object",
6768
6736
  properties: {
6769
- image: GpuImageSchema5({ title: "Image", description: "Source image" }),
6737
+ image: ImageValueSchema5({ title: "Image", description: "Source image" }),
6770
6738
  left: { type: "integer", title: "Left", description: "Left offset", minimum: 0, default: 0 },
6771
6739
  top: { type: "integer", title: "Top", description: "Top offset", minimum: 0, default: 0 },
6772
6740
  width: { type: "integer", title: "Width", description: "Crop width", minimum: 1 },
@@ -6777,7 +6745,7 @@ var inputSchema45 = {
6777
6745
  };
6778
6746
  var outputSchema44 = {
6779
6747
  type: "object",
6780
- properties: { image: GpuImageSchema5({ title: "Image", description: "Cropped image" }) },
6748
+ properties: { image: ImageValueSchema5({ title: "Image", description: "Cropped image" }) },
6781
6749
  required: ["image"],
6782
6750
  additionalProperties: false
6783
6751
  };
@@ -6814,11 +6782,11 @@ class ImageCropTask extends ImageFilterTask {
6814
6782
  Workflow21.prototype.imageCrop = CreateWorkflow20(ImageCropTask);
6815
6783
  // src/task/image/flip/ImageFlipTask.ts
6816
6784
  import { CreateWorkflow as CreateWorkflow21, Workflow as Workflow22 } from "@workglow/task-graph";
6817
- import { GpuImageSchema as GpuImageSchema6 } from "@workglow/util/media";
6785
+ import { ImageValueSchema as ImageValueSchema6 } from "@workglow/util/media";
6818
6786
  var inputSchema46 = {
6819
6787
  type: "object",
6820
6788
  properties: {
6821
- image: GpuImageSchema6({ title: "Image", description: "Source image" }),
6789
+ image: ImageValueSchema6({ title: "Image", description: "Source image" }),
6822
6790
  direction: {
6823
6791
  type: "string",
6824
6792
  enum: ["horizontal", "vertical"],
@@ -6832,7 +6800,7 @@ var inputSchema46 = {
6832
6800
  };
6833
6801
  var outputSchema45 = {
6834
6802
  type: "object",
6835
- properties: { image: GpuImageSchema6({ title: "Image", description: "Flipped image" }) },
6803
+ properties: { image: ImageValueSchema6({ title: "Image", description: "Flipped image" }) },
6836
6804
  required: ["image"],
6837
6805
  additionalProperties: false
6838
6806
  };
@@ -6856,16 +6824,16 @@ class ImageFlipTask extends ImageFilterTask {
6856
6824
  Workflow22.prototype.imageFlip = CreateWorkflow21(ImageFlipTask);
6857
6825
  // src/task/image/grayscale/ImageGrayscaleTask.ts
6858
6826
  import { CreateWorkflow as CreateWorkflow22, Workflow as Workflow23 } from "@workglow/task-graph";
6859
- import { GpuImageSchema as GpuImageSchema7 } from "@workglow/util/media";
6827
+ import { ImageValueSchema as ImageValueSchema7 } from "@workglow/util/media";
6860
6828
  var inputSchema47 = {
6861
6829
  type: "object",
6862
- properties: { image: GpuImageSchema7({ title: "Image", description: "Source image" }) },
6830
+ properties: { image: ImageValueSchema7({ title: "Image", description: "Source image" }) },
6863
6831
  required: ["image"],
6864
6832
  additionalProperties: false
6865
6833
  };
6866
6834
  var outputSchema46 = {
6867
6835
  type: "object",
6868
- properties: { image: GpuImageSchema7({ title: "Image", description: "Grayscale image" }) },
6836
+ properties: { image: ImageValueSchema7({ title: "Image", description: "Grayscale image" }) },
6869
6837
  required: ["image"],
6870
6838
  additionalProperties: false
6871
6839
  };
@@ -6889,16 +6857,16 @@ class ImageGrayscaleTask extends ImageFilterTask {
6889
6857
  Workflow23.prototype.imageGrayscale = CreateWorkflow22(ImageGrayscaleTask);
6890
6858
  // src/task/image/invert/ImageInvertTask.ts
6891
6859
  import { CreateWorkflow as CreateWorkflow23, Workflow as Workflow24 } from "@workglow/task-graph";
6892
- import { GpuImageSchema as GpuImageSchema8 } from "@workglow/util/media";
6860
+ import { ImageValueSchema as ImageValueSchema8 } from "@workglow/util/media";
6893
6861
  var inputSchema48 = {
6894
6862
  type: "object",
6895
- properties: { image: GpuImageSchema8({ title: "Image", description: "Source image" }) },
6863
+ properties: { image: ImageValueSchema8({ title: "Image", description: "Source image" }) },
6896
6864
  required: ["image"],
6897
6865
  additionalProperties: false
6898
6866
  };
6899
6867
  var outputSchema47 = {
6900
6868
  type: "object",
6901
- properties: { image: GpuImageSchema8({ title: "Image", description: "Inverted image" }) },
6869
+ properties: { image: ImageValueSchema8({ title: "Image", description: "Inverted image" }) },
6902
6870
  required: ["image"],
6903
6871
  additionalProperties: false
6904
6872
  };
@@ -6922,11 +6890,11 @@ class ImageInvertTask extends ImageFilterTask {
6922
6890
  Workflow24.prototype.imageInvert = CreateWorkflow23(ImageInvertTask);
6923
6891
  // src/task/image/pixelate/ImagePixelateTask.ts
6924
6892
  import { CreateWorkflow as CreateWorkflow24, Workflow as Workflow25 } from "@workglow/task-graph";
6925
- import { GpuImageSchema as GpuImageSchema9 } from "@workglow/util/media";
6893
+ import { ImageValueSchema as ImageValueSchema9 } from "@workglow/util/media";
6926
6894
  var inputSchema49 = {
6927
6895
  type: "object",
6928
6896
  properties: {
6929
- image: GpuImageSchema9({ title: "Image", description: "Source image" }),
6897
+ image: ImageValueSchema9({ title: "Image", description: "Source image" }),
6930
6898
  blockSize: {
6931
6899
  type: "integer",
6932
6900
  title: "Block Size",
@@ -6941,7 +6909,7 @@ var inputSchema49 = {
6941
6909
  };
6942
6910
  var outputSchema48 = {
6943
6911
  type: "object",
6944
- properties: { image: GpuImageSchema9({ title: "Image", description: "Pixelated image" }) },
6912
+ properties: { image: ImageValueSchema9({ title: "Image", description: "Pixelated image" }) },
6945
6913
  required: ["image"],
6946
6914
  additionalProperties: false
6947
6915
  };
@@ -6968,11 +6936,11 @@ class ImagePixelateTask extends ImageFilterTask {
6968
6936
  Workflow25.prototype.imagePixelate = CreateWorkflow24(ImagePixelateTask);
6969
6937
  // src/task/image/posterize/ImagePosterizeTask.ts
6970
6938
  import { CreateWorkflow as CreateWorkflow25, Workflow as Workflow26 } from "@workglow/task-graph";
6971
- import { GpuImageSchema as GpuImageSchema10 } from "@workglow/util/media";
6939
+ import { ImageValueSchema as ImageValueSchema10 } from "@workglow/util/media";
6972
6940
  var inputSchema50 = {
6973
6941
  type: "object",
6974
6942
  properties: {
6975
- image: GpuImageSchema10({ title: "Image", description: "Source image" }),
6943
+ image: ImageValueSchema10({ title: "Image", description: "Source image" }),
6976
6944
  levels: {
6977
6945
  type: "integer",
6978
6946
  title: "Levels",
@@ -6987,7 +6955,7 @@ var inputSchema50 = {
6987
6955
  };
6988
6956
  var outputSchema49 = {
6989
6957
  type: "object",
6990
- properties: { image: GpuImageSchema10({ title: "Image", description: "Posterized image" }) },
6958
+ properties: { image: ImageValueSchema10({ title: "Image", description: "Posterized image" }) },
6991
6959
  required: ["image"],
6992
6960
  additionalProperties: false
6993
6961
  };
@@ -7013,11 +6981,11 @@ Workflow26.prototype.imagePosterize = CreateWorkflow25(ImagePosterizeTask);
7013
6981
  import { getImageRasterCodec, registerImageRasterCodec as registerImageRasterCodec2 } from "@workglow/util/media";
7014
6982
  // src/task/image/resize/ImageResizeTask.ts
7015
6983
  import { CreateWorkflow as CreateWorkflow26, Workflow as Workflow27 } from "@workglow/task-graph";
7016
- import { GpuImageSchema as GpuImageSchema11 } from "@workglow/util/media";
6984
+ import { ImageValueSchema as ImageValueSchema11 } from "@workglow/util/media";
7017
6985
  var inputSchema51 = {
7018
6986
  type: "object",
7019
6987
  properties: {
7020
- image: GpuImageSchema11({ title: "Image", description: "Source image" }),
6988
+ image: ImageValueSchema11({ title: "Image", description: "Source image" }),
7021
6989
  width: { type: "integer", title: "Width", description: "Target width in pixels", minimum: 1 },
7022
6990
  height: { type: "integer", title: "Height", description: "Target height in pixels", minimum: 1 },
7023
6991
  fit: {
@@ -7038,7 +7006,7 @@ var inputSchema51 = {
7038
7006
  };
7039
7007
  var outputSchema50 = {
7040
7008
  type: "object",
7041
- properties: { image: GpuImageSchema11({ title: "Image", description: "Resized image" }) },
7009
+ properties: { image: ImageValueSchema11({ title: "Image", description: "Resized image" }) },
7042
7010
  required: ["image"],
7043
7011
  additionalProperties: false
7044
7012
  };
@@ -7075,11 +7043,11 @@ class ImageResizeTask extends ImageFilterTask {
7075
7043
  Workflow27.prototype.imageResize = CreateWorkflow26(ImageResizeTask);
7076
7044
  // src/task/image/rotate/ImageRotateTask.ts
7077
7045
  import { CreateWorkflow as CreateWorkflow27, Workflow as Workflow28 } from "@workglow/task-graph";
7078
- import { GpuImageSchema as GpuImageSchema12 } from "@workglow/util/media";
7046
+ import { ImageValueSchema as ImageValueSchema12 } from "@workglow/util/media";
7079
7047
  var inputSchema52 = {
7080
7048
  type: "object",
7081
7049
  properties: {
7082
- image: GpuImageSchema12({ title: "Image", description: "Source image" }),
7050
+ image: ImageValueSchema12({ title: "Image", description: "Source image" }),
7083
7051
  angle: {
7084
7052
  type: "integer",
7085
7053
  enum: [90, 180, 270],
@@ -7097,7 +7065,7 @@ var inputSchema52 = {
7097
7065
  };
7098
7066
  var outputSchema51 = {
7099
7067
  type: "object",
7100
- properties: { image: GpuImageSchema12({ title: "Image", description: "Rotated image" }) },
7068
+ properties: { image: ImageValueSchema12({ title: "Image", description: "Rotated image" }) },
7101
7069
  required: ["image"],
7102
7070
  additionalProperties: false
7103
7071
  };
@@ -7179,16 +7147,16 @@ var ColorFromSchemaOptions = {
7179
7147
  };
7180
7148
  // src/task/image/sepia/ImageSepiaTask.ts
7181
7149
  import { CreateWorkflow as CreateWorkflow28, Workflow as Workflow29 } from "@workglow/task-graph";
7182
- import { GpuImageSchema as GpuImageSchema13 } from "@workglow/util/media";
7150
+ import { ImageValueSchema as ImageValueSchema13 } from "@workglow/util/media";
7183
7151
  var inputSchema53 = {
7184
7152
  type: "object",
7185
- properties: { image: GpuImageSchema13({ title: "Image", description: "Source image" }) },
7153
+ properties: { image: ImageValueSchema13({ title: "Image", description: "Source image" }) },
7186
7154
  required: ["image"],
7187
7155
  additionalProperties: false
7188
7156
  };
7189
7157
  var outputSchema52 = {
7190
7158
  type: "object",
7191
- properties: { image: GpuImageSchema13({ title: "Image", description: "Sepia-toned image" }) },
7159
+ properties: { image: ImageValueSchema13({ title: "Image", description: "Sepia-toned image" }) },
7192
7160
  required: ["image"],
7193
7161
  additionalProperties: false
7194
7162
  };
@@ -7219,7 +7187,7 @@ import {
7219
7187
  import {
7220
7188
  CpuImage as CpuImage18,
7221
7189
  getPreviewBudget,
7222
- GpuImageSchema as GpuImageSchema14,
7190
+ ImageValueSchema as ImageValueSchema14,
7223
7191
  resolveColor as resolveColor5
7224
7192
  } from "@workglow/util/media";
7225
7193
  function toRgbaImage(image) {
@@ -7296,7 +7264,7 @@ var IMAGE_TEXT_POSITION_LABELS = {
7296
7264
  "bottom-center": "Bottom center",
7297
7265
  "bottom-right": "Bottom right"
7298
7266
  };
7299
- var backgroundImageProperty = GpuImageSchema14({
7267
+ var backgroundImageProperty = ImageValueSchema14({
7300
7268
  title: "Image",
7301
7269
  description: "Background image to render the text onto"
7302
7270
  });
@@ -7361,7 +7329,7 @@ var inputSchema54 = {
7361
7329
  var outputSchema53 = {
7362
7330
  type: "object",
7363
7331
  properties: {
7364
- image: GpuImageSchema14({ title: "Image", description: "Raster image with text" })
7332
+ image: ImageValueSchema14({ title: "Image", description: "Raster image with text" })
7365
7333
  },
7366
7334
  required: ["image"],
7367
7335
  additionalProperties: false
@@ -7384,7 +7352,8 @@ function requireStandaloneDims(input) {
7384
7352
  return { width: input.width, height: input.height };
7385
7353
  }
7386
7354
  async function renderTextOverBackground(params, backgroundImage, previewScale) {
7387
- const background = await backgroundImage.materialize();
7355
+ const cpu = await CpuImage18.from(backgroundImage);
7356
+ const background = cpu.getBinary();
7388
7357
  const overlay = await renderImageTextToRgba({
7389
7358
  text: params.text,
7390
7359
  font: params.font,
@@ -7398,7 +7367,7 @@ async function renderTextOverBackground(params, backgroundImage, previewScale) {
7398
7367
  });
7399
7368
  const composited = compositeTextOverBackground(background, overlay);
7400
7369
  return {
7401
- image: CpuImage18.fromImageBinary(composited, previewScale)
7370
+ image: await CpuImage18.fromRaw(composited).toImageValue(previewScale)
7402
7371
  };
7403
7372
  }
7404
7373
  async function renderTextStandalone(params, width, height, previewScale) {
@@ -7414,7 +7383,7 @@ async function renderTextStandalone(params, width, height, previewScale) {
7414
7383
  position: params.position
7415
7384
  });
7416
7385
  return {
7417
- image: CpuImage18.fromImageBinary(textBinary, previewScale)
7386
+ image: await CpuImage18.fromRaw(textBinary).toImageValue(previewScale)
7418
7387
  };
7419
7388
  }
7420
7389
  async function runText(input) {
@@ -7464,11 +7433,11 @@ class ImageTextTask extends Task43 {
7464
7433
  Workflow30.prototype.imageText = CreateWorkflow29(ImageTextTask);
7465
7434
  // src/task/image/threshold/ImageThresholdTask.ts
7466
7435
  import { CreateWorkflow as CreateWorkflow30, Workflow as Workflow31 } from "@workglow/task-graph";
7467
- import { GpuImageSchema as GpuImageSchema15 } from "@workglow/util/media";
7436
+ import { ImageValueSchema as ImageValueSchema15 } from "@workglow/util/media";
7468
7437
  var inputSchema55 = {
7469
7438
  type: "object",
7470
7439
  properties: {
7471
- image: GpuImageSchema15({ title: "Image", description: "Source image" }),
7440
+ image: ImageValueSchema15({ title: "Image", description: "Source image" }),
7472
7441
  value: {
7473
7442
  type: "number",
7474
7443
  title: "Value",
@@ -7483,7 +7452,7 @@ var inputSchema55 = {
7483
7452
  };
7484
7453
  var outputSchema54 = {
7485
7454
  type: "object",
7486
- properties: { image: GpuImageSchema15({ title: "Image", description: "Thresholded image" }) },
7455
+ properties: { image: ImageValueSchema15({ title: "Image", description: "Thresholded image" }) },
7487
7456
  required: ["image"],
7488
7457
  additionalProperties: false
7489
7458
  };
@@ -7507,11 +7476,11 @@ class ImageThresholdTask extends ImageFilterTask {
7507
7476
  Workflow31.prototype.imageThreshold = CreateWorkflow30(ImageThresholdTask);
7508
7477
  // src/task/image/tint/ImageTintTask.ts
7509
7478
  import { CreateWorkflow as CreateWorkflow31, Workflow as Workflow32 } from "@workglow/task-graph";
7510
- import { GpuImageSchema as GpuImageSchema16 } from "@workglow/util/media";
7479
+ import { ImageValueSchema as ImageValueSchema16 } from "@workglow/util/media";
7511
7480
  var inputSchema56 = {
7512
7481
  type: "object",
7513
7482
  properties: {
7514
- image: GpuImageSchema16({ title: "Image", description: "Source image" }),
7483
+ image: ImageValueSchema16({ title: "Image", description: "Source image" }),
7515
7484
  color: ColorValueSchema({ title: "Color", description: "Tint color" }),
7516
7485
  amount: {
7517
7486
  type: "number",
@@ -7527,7 +7496,7 @@ var inputSchema56 = {
7527
7496
  };
7528
7497
  var outputSchema55 = {
7529
7498
  type: "object",
7530
- properties: { image: GpuImageSchema16({ title: "Image", description: "Tinted image" }) },
7499
+ properties: { image: ImageValueSchema16({ title: "Image", description: "Tinted image" }) },
7531
7500
  required: ["image"],
7532
7501
  additionalProperties: false
7533
7502
  };
@@ -7554,11 +7523,11 @@ class ImageTintTask extends ImageFilterTask {
7554
7523
  Workflow32.prototype.imageTint = CreateWorkflow31(ImageTintTask);
7555
7524
  // src/task/image/transparency/ImageTransparencyTask.ts
7556
7525
  import { CreateWorkflow as CreateWorkflow32, Workflow as Workflow33 } from "@workglow/task-graph";
7557
- import { GpuImageSchema as GpuImageSchema17 } from "@workglow/util/media";
7526
+ import { ImageValueSchema as ImageValueSchema17 } from "@workglow/util/media";
7558
7527
  var inputSchema57 = {
7559
7528
  type: "object",
7560
7529
  properties: {
7561
- image: GpuImageSchema17({ title: "Image", description: "Source image" }),
7530
+ image: ImageValueSchema17({ title: "Image", description: "Source image" }),
7562
7531
  amount: {
7563
7532
  type: "number",
7564
7533
  title: "Amount",
@@ -7573,7 +7542,7 @@ var inputSchema57 = {
7573
7542
  };
7574
7543
  var outputSchema56 = {
7575
7544
  type: "object",
7576
- properties: { image: GpuImageSchema17({ title: "Image", description: "Image with adjusted transparency" }) },
7545
+ properties: { image: ImageValueSchema17({ title: "Image", description: "Image with adjusted transparency" }) },
7577
7546
  required: ["image"],
7578
7547
  additionalProperties: false
7579
7548
  };
@@ -16602,4 +16571,4 @@ export {
16602
16571
  ArrayTask
16603
16572
  };
16604
16573
 
16605
- //# debugId=FAF7FA49938F2E7164756E2164756E21
16574
+ //# debugId=C616C723AAF9A52064756E2164756E21