@workglow/tasks 0.2.0 → 0.2.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.
Files changed (51) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.d.ts.map +1 -1
  3. package/dist/browser.js +1265 -11
  4. package/dist/browser.js.map +22 -4
  5. package/dist/bun.d.ts +1 -1
  6. package/dist/bun.d.ts.map +1 -1
  7. package/dist/bun.js +1268 -14
  8. package/dist/bun.js.map +22 -4
  9. package/dist/common.d.ts +36 -1
  10. package/dist/common.d.ts.map +1 -1
  11. package/dist/node.d.ts +1 -1
  12. package/dist/node.d.ts.map +1 -1
  13. package/dist/node.js +1268 -14
  14. package/dist/node.js.map +22 -4
  15. package/dist/task/image/ImageBlurTask.d.ts +219 -0
  16. package/dist/task/image/ImageBlurTask.d.ts.map +1 -0
  17. package/dist/task/image/ImageBorderTask.d.ts +281 -0
  18. package/dist/task/image/ImageBorderTask.d.ts.map +1 -0
  19. package/dist/task/image/ImageBrightnessTask.d.ts +219 -0
  20. package/dist/task/image/ImageBrightnessTask.d.ts.map +1 -0
  21. package/dist/task/image/ImageContrastTask.d.ts +219 -0
  22. package/dist/task/image/ImageContrastTask.d.ts.map +1 -0
  23. package/dist/task/image/ImageCropTask.d.ts +251 -0
  24. package/dist/task/image/ImageCropTask.d.ts.map +1 -0
  25. package/dist/task/image/ImageFlipTask.d.ts +215 -0
  26. package/dist/task/image/ImageFlipTask.d.ts.map +1 -0
  27. package/dist/task/image/ImageGrayscaleTask.d.ts +203 -0
  28. package/dist/task/image/ImageGrayscaleTask.d.ts.map +1 -0
  29. package/dist/task/image/ImageInvertTask.d.ts +203 -0
  30. package/dist/task/image/ImageInvertTask.d.ts.map +1 -0
  31. package/dist/task/image/ImagePixelateTask.d.ts +217 -0
  32. package/dist/task/image/ImagePixelateTask.d.ts.map +1 -0
  33. package/dist/task/image/ImagePosterizeTask.d.ts +219 -0
  34. package/dist/task/image/ImagePosterizeTask.d.ts.map +1 -0
  35. package/dist/task/image/ImageResizeTask.d.ts +227 -0
  36. package/dist/task/image/ImageResizeTask.d.ts.map +1 -0
  37. package/dist/task/image/ImageRotateTask.d.ts +215 -0
  38. package/dist/task/image/ImageRotateTask.d.ts.map +1 -0
  39. package/dist/task/image/ImageSchemas.d.ts +94 -0
  40. package/dist/task/image/ImageSchemas.d.ts.map +1 -0
  41. package/dist/task/image/ImageSepiaTask.d.ts +203 -0
  42. package/dist/task/image/ImageSepiaTask.d.ts.map +1 -0
  43. package/dist/task/image/ImageThresholdTask.d.ts +219 -0
  44. package/dist/task/image/ImageThresholdTask.d.ts.map +1 -0
  45. package/dist/task/image/ImageTintTask.d.ts +283 -0
  46. package/dist/task/image/ImageTintTask.d.ts.map +1 -0
  47. package/dist/task/image/ImageTransparencyTask.d.ts +217 -0
  48. package/dist/task/image/ImageTransparencyTask.d.ts.map +1 -0
  49. package/dist/task/image/ImageWatermarkTask.d.ts +247 -0
  50. package/dist/task/image/ImageWatermarkTask.d.ts.map +1 -0
  51. package/package.json +9 -9
package/dist/browser.js CHANGED
@@ -9945,6 +9945,1223 @@ class VectorScaleTask extends Task50 {
9945
9945
  }
9946
9946
  }
9947
9947
  Workflow52.prototype.vectorScale = CreateWorkflow51(VectorScaleTask);
9948
+ // src/task/image/ImageSchemas.ts
9949
+ import { FromSchemaDefaultOptions } from "@workglow/util/schema";
9950
+ var ImageBinaryType = null;
9951
+ var ImageBinarySchemaOptions = {
9952
+ ...FromSchemaDefaultOptions,
9953
+ deserialize: [
9954
+ {
9955
+ pattern: { type: "object", format: "image:ImageBinary" },
9956
+ output: ImageBinaryType
9957
+ }
9958
+ ]
9959
+ };
9960
+ var ImageBinarySchema = (annotations = {}) => ({
9961
+ type: "object",
9962
+ properties: {
9963
+ data: {
9964
+ type: "array",
9965
+ items: { type: "number", format: "Uint8Clamped" },
9966
+ format: "Uint8ClampedArray",
9967
+ title: "Data",
9968
+ description: "Pixel data of the image"
9969
+ },
9970
+ width: {
9971
+ type: "integer",
9972
+ minimum: 1,
9973
+ title: "Width",
9974
+ description: "Width in pixels"
9975
+ },
9976
+ height: {
9977
+ type: "integer",
9978
+ minimum: 1,
9979
+ title: "Height",
9980
+ description: "Height in pixels"
9981
+ },
9982
+ channels: {
9983
+ type: "integer",
9984
+ enum: [1, 3, 4],
9985
+ title: "Channels",
9986
+ description: "1 (gray), 3 (RGB), or 4 (RGBA)"
9987
+ }
9988
+ },
9989
+ additionalProperties: false,
9990
+ required: ["data", "width", "height", "channels"],
9991
+ format: "image:ImageBinary",
9992
+ title: "Image",
9993
+ description: "Raw pixel image data",
9994
+ ...annotations
9995
+ });
9996
+ var ColorSchema = (annotations = {}) => ({
9997
+ type: "object",
9998
+ properties: {
9999
+ r: { type: "integer", minimum: 0, maximum: 255, title: "Red" },
10000
+ g: { type: "integer", minimum: 0, maximum: 255, title: "Green" },
10001
+ b: { type: "integer", minimum: 0, maximum: 255, title: "Blue" },
10002
+ a: { type: "integer", minimum: 0, maximum: 255, title: "Alpha", default: 255 }
10003
+ },
10004
+ required: ["r", "g", "b"],
10005
+ additionalProperties: false,
10006
+ ...annotations
10007
+ });
10008
+ // src/task/image/ImageResizeTask.ts
10009
+ import {
10010
+ CreateWorkflow as CreateWorkflow52,
10011
+ Task as Task51,
10012
+ Workflow as Workflow53
10013
+ } from "@workglow/task-graph";
10014
+ var inputSchema45 = {
10015
+ type: "object",
10016
+ properties: {
10017
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10018
+ width: { type: "integer", title: "Width", description: "Target width in pixels", minimum: 1 },
10019
+ height: {
10020
+ type: "integer",
10021
+ title: "Height",
10022
+ description: "Target height in pixels",
10023
+ minimum: 1
10024
+ }
10025
+ },
10026
+ required: ["image", "width", "height"],
10027
+ additionalProperties: false
10028
+ };
10029
+ var outputSchema44 = {
10030
+ type: "object",
10031
+ properties: {
10032
+ image: ImageBinarySchema({ title: "Image", description: "Resized image" })
10033
+ },
10034
+ required: ["image"],
10035
+ additionalProperties: false
10036
+ };
10037
+
10038
+ class ImageResizeTask extends Task51 {
10039
+ static type = "ImageResizeTask";
10040
+ static category = "Image";
10041
+ static title = "Resize Image";
10042
+ static description = "Resizes an image using nearest-neighbor sampling";
10043
+ static inputSchema() {
10044
+ return inputSchema45;
10045
+ }
10046
+ static outputSchema() {
10047
+ return outputSchema44;
10048
+ }
10049
+ async executeReactive(input2, _output, _context) {
10050
+ const { image, width: dstW, height: dstH } = input2;
10051
+ const { data: src, width: srcW, height: srcH, channels } = image;
10052
+ const dst = new Uint8ClampedArray(dstW * dstH * channels);
10053
+ for (let dy = 0;dy < dstH; dy++) {
10054
+ const srcY = Math.min(Math.floor(dy * srcH / dstH), srcH - 1);
10055
+ for (let dx = 0;dx < dstW; dx++) {
10056
+ const srcX = Math.min(Math.floor(dx * srcW / dstW), srcW - 1);
10057
+ const srcIdx = (srcY * srcW + srcX) * channels;
10058
+ const dstIdx = (dy * dstW + dx) * channels;
10059
+ for (let c = 0;c < channels; c++) {
10060
+ dst[dstIdx + c] = src[srcIdx + c];
10061
+ }
10062
+ }
10063
+ }
10064
+ return {
10065
+ image: { data: dst, width: dstW, height: dstH, channels }
10066
+ };
10067
+ }
10068
+ }
10069
+ Workflow53.prototype.imageResize = CreateWorkflow52(ImageResizeTask);
10070
+ // src/task/image/ImageCropTask.ts
10071
+ import {
10072
+ CreateWorkflow as CreateWorkflow53,
10073
+ Task as Task52,
10074
+ Workflow as Workflow54
10075
+ } from "@workglow/task-graph";
10076
+ var inputSchema46 = {
10077
+ type: "object",
10078
+ properties: {
10079
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10080
+ x: { type: "integer", title: "X", description: "Left offset", minimum: 0 },
10081
+ y: { type: "integer", title: "Y", description: "Top offset", minimum: 0 },
10082
+ width: { type: "integer", title: "Width", description: "Crop width", minimum: 1 },
10083
+ height: { type: "integer", title: "Height", description: "Crop height", minimum: 1 }
10084
+ },
10085
+ required: ["image", "x", "y", "width", "height"],
10086
+ additionalProperties: false
10087
+ };
10088
+ var outputSchema45 = {
10089
+ type: "object",
10090
+ properties: {
10091
+ image: ImageBinarySchema({ title: "Image", description: "Cropped image" })
10092
+ },
10093
+ required: ["image"],
10094
+ additionalProperties: false
10095
+ };
10096
+
10097
+ class ImageCropTask extends Task52 {
10098
+ static type = "ImageCropTask";
10099
+ static category = "Image";
10100
+ static title = "Crop Image";
10101
+ static description = "Crops an image to a rectangular region";
10102
+ static inputSchema() {
10103
+ return inputSchema46;
10104
+ }
10105
+ static outputSchema() {
10106
+ return outputSchema45;
10107
+ }
10108
+ async executeReactive(input2, _output, _context) {
10109
+ const { image, x: rawX, y: rawY, width: rawW, height: rawH } = input2;
10110
+ const { data: src, width: srcW, height: srcH, channels } = image;
10111
+ if (srcW < 1 || srcH < 1) {
10112
+ throw new RangeError("Cannot crop an empty image");
10113
+ }
10114
+ if (rawX < 0 || rawX >= srcW || rawY < 0 || rawY >= srcH) {
10115
+ throw new RangeError("Crop origin is outside the source image bounds");
10116
+ }
10117
+ const x = rawX;
10118
+ const y = rawY;
10119
+ const w = Math.min(rawW, srcW - x);
10120
+ const h = Math.min(rawH, srcH - y);
10121
+ const dst = new Uint8ClampedArray(w * h * channels);
10122
+ const rowBytes = w * channels;
10123
+ for (let row = 0;row < h; row++) {
10124
+ const srcOffset = ((y + row) * srcW + x) * channels;
10125
+ const dstOffset = row * rowBytes;
10126
+ dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
10127
+ }
10128
+ return { image: { data: dst, width: w, height: h, channels } };
10129
+ }
10130
+ }
10131
+ Workflow54.prototype.imageCrop = CreateWorkflow53(ImageCropTask);
10132
+ // src/task/image/ImageRotateTask.ts
10133
+ import {
10134
+ CreateWorkflow as CreateWorkflow54,
10135
+ Task as Task53,
10136
+ Workflow as Workflow55
10137
+ } from "@workglow/task-graph";
10138
+ var inputSchema47 = {
10139
+ type: "object",
10140
+ properties: {
10141
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10142
+ angle: {
10143
+ type: "integer",
10144
+ enum: [90, 180, 270],
10145
+ title: "Angle",
10146
+ description: "Rotation angle in degrees (clockwise)"
10147
+ }
10148
+ },
10149
+ required: ["image", "angle"],
10150
+ additionalProperties: false
10151
+ };
10152
+ var outputSchema46 = {
10153
+ type: "object",
10154
+ properties: {
10155
+ image: ImageBinarySchema({ title: "Image", description: "Rotated image" })
10156
+ },
10157
+ required: ["image"],
10158
+ additionalProperties: false
10159
+ };
10160
+
10161
+ class ImageRotateTask extends Task53 {
10162
+ static type = "ImageRotateTask";
10163
+ static category = "Image";
10164
+ static title = "Rotate Image";
10165
+ static description = "Rotates an image by 90, 180, or 270 degrees clockwise";
10166
+ static inputSchema() {
10167
+ return inputSchema47;
10168
+ }
10169
+ static outputSchema() {
10170
+ return outputSchema46;
10171
+ }
10172
+ async executeReactive(input2, _output, _context) {
10173
+ const { image, angle } = input2;
10174
+ const { data: src, width: srcW, height: srcH, channels } = image;
10175
+ const swap = angle === 90 || angle === 270;
10176
+ const dstW = swap ? srcH : srcW;
10177
+ const dstH = swap ? srcW : srcH;
10178
+ const dst = new Uint8ClampedArray(dstW * dstH * channels);
10179
+ for (let sy = 0;sy < srcH; sy++) {
10180
+ for (let sx = 0;sx < srcW; sx++) {
10181
+ let dx, dy;
10182
+ if (angle === 90) {
10183
+ dx = srcH - 1 - sy;
10184
+ dy = sx;
10185
+ } else if (angle === 180) {
10186
+ dx = srcW - 1 - sx;
10187
+ dy = srcH - 1 - sy;
10188
+ } else {
10189
+ dx = sy;
10190
+ dy = srcW - 1 - sx;
10191
+ }
10192
+ const srcIdx = (sy * srcW + sx) * channels;
10193
+ const dstIdx = (dy * dstW + dx) * channels;
10194
+ for (let c = 0;c < channels; c++) {
10195
+ dst[dstIdx + c] = src[srcIdx + c];
10196
+ }
10197
+ }
10198
+ }
10199
+ return {
10200
+ image: { data: dst, width: dstW, height: dstH, channels }
10201
+ };
10202
+ }
10203
+ }
10204
+ Workflow55.prototype.imageRotate = CreateWorkflow54(ImageRotateTask);
10205
+ // src/task/image/ImageFlipTask.ts
10206
+ import {
10207
+ CreateWorkflow as CreateWorkflow55,
10208
+ Task as Task54,
10209
+ Workflow as Workflow56
10210
+ } from "@workglow/task-graph";
10211
+ var inputSchema48 = {
10212
+ type: "object",
10213
+ properties: {
10214
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10215
+ direction: {
10216
+ type: "string",
10217
+ enum: ["horizontal", "vertical"],
10218
+ title: "Direction",
10219
+ description: "Flip direction"
10220
+ }
10221
+ },
10222
+ required: ["image", "direction"],
10223
+ additionalProperties: false
10224
+ };
10225
+ var outputSchema47 = {
10226
+ type: "object",
10227
+ properties: {
10228
+ image: ImageBinarySchema({ title: "Image", description: "Flipped image" })
10229
+ },
10230
+ required: ["image"],
10231
+ additionalProperties: false
10232
+ };
10233
+
10234
+ class ImageFlipTask extends Task54 {
10235
+ static type = "ImageFlipTask";
10236
+ static category = "Image";
10237
+ static title = "Flip Image";
10238
+ static description = "Flips an image horizontally or vertically";
10239
+ static inputSchema() {
10240
+ return inputSchema48;
10241
+ }
10242
+ static outputSchema() {
10243
+ return outputSchema47;
10244
+ }
10245
+ async executeReactive(input2, _output, _context) {
10246
+ const { image, direction } = input2;
10247
+ const { data: src, width, height, channels } = image;
10248
+ const dst = new Uint8ClampedArray(src.length);
10249
+ const rowBytes = width * channels;
10250
+ if (direction === "vertical") {
10251
+ for (let y = 0;y < height; y++) {
10252
+ const srcOffset = y * rowBytes;
10253
+ const dstOffset = (height - 1 - y) * rowBytes;
10254
+ dst.set(src.subarray(srcOffset, srcOffset + rowBytes), dstOffset);
10255
+ }
10256
+ } else {
10257
+ for (let y = 0;y < height; y++) {
10258
+ for (let x = 0;x < width; x++) {
10259
+ const srcIdx = (y * width + x) * channels;
10260
+ const dstIdx = (y * width + (width - 1 - x)) * channels;
10261
+ for (let c = 0;c < channels; c++) {
10262
+ dst[dstIdx + c] = src[srcIdx + c];
10263
+ }
10264
+ }
10265
+ }
10266
+ }
10267
+ return { image: { data: dst, width, height, channels } };
10268
+ }
10269
+ }
10270
+ Workflow56.prototype.imageFlip = CreateWorkflow55(ImageFlipTask);
10271
+ // src/task/image/ImageGrayscaleTask.ts
10272
+ import {
10273
+ CreateWorkflow as CreateWorkflow56,
10274
+ Task as Task55,
10275
+ Workflow as Workflow57
10276
+ } from "@workglow/task-graph";
10277
+ var inputSchema49 = {
10278
+ type: "object",
10279
+ properties: {
10280
+ image: ImageBinarySchema({ title: "Image", description: "Source image" })
10281
+ },
10282
+ required: ["image"],
10283
+ additionalProperties: false
10284
+ };
10285
+ var outputSchema48 = {
10286
+ type: "object",
10287
+ properties: {
10288
+ image: ImageBinarySchema({ title: "Image", description: "Grayscale image" })
10289
+ },
10290
+ required: ["image"],
10291
+ additionalProperties: false
10292
+ };
10293
+
10294
+ class ImageGrayscaleTask extends Task55 {
10295
+ static type = "ImageGrayscaleTask";
10296
+ static category = "Image";
10297
+ static title = "Grayscale";
10298
+ static description = "Converts an image to grayscale using luminance";
10299
+ static inputSchema() {
10300
+ return inputSchema49;
10301
+ }
10302
+ static outputSchema() {
10303
+ return outputSchema48;
10304
+ }
10305
+ async executeReactive(input2, _output, _context) {
10306
+ const { data: src, width, height, channels } = input2.image;
10307
+ if (channels === 1) {
10308
+ return { image: { data: new Uint8ClampedArray(src), width, height, channels: 1 } };
10309
+ }
10310
+ const pixelCount = width * height;
10311
+ const dst = new Uint8ClampedArray(pixelCount);
10312
+ for (let i = 0;i < pixelCount; i++) {
10313
+ const idx = i * channels;
10314
+ dst[i] = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
10315
+ }
10316
+ return { image: { data: dst, width, height, channels: 1 } };
10317
+ }
10318
+ }
10319
+ Workflow57.prototype.imageGrayscale = CreateWorkflow56(ImageGrayscaleTask);
10320
+ // src/task/image/ImageBorderTask.ts
10321
+ import {
10322
+ CreateWorkflow as CreateWorkflow57,
10323
+ Task as Task56,
10324
+ Workflow as Workflow58
10325
+ } from "@workglow/task-graph";
10326
+ var inputSchema50 = {
10327
+ type: "object",
10328
+ properties: {
10329
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10330
+ borderWidth: {
10331
+ type: "integer",
10332
+ title: "Border Width",
10333
+ description: "Border width in pixels",
10334
+ minimum: 1,
10335
+ default: 1
10336
+ },
10337
+ color: ColorSchema({ title: "Color", description: "Border color" })
10338
+ },
10339
+ required: ["image", "color"],
10340
+ additionalProperties: false
10341
+ };
10342
+ var outputSchema49 = {
10343
+ type: "object",
10344
+ properties: {
10345
+ image: ImageBinarySchema({ title: "Image", description: "Image with border" })
10346
+ },
10347
+ required: ["image"],
10348
+ additionalProperties: false
10349
+ };
10350
+
10351
+ class ImageBorderTask extends Task56 {
10352
+ static type = "ImageBorderTask";
10353
+ static category = "Image";
10354
+ static title = "Add Border";
10355
+ static description = "Adds a colored border around an image";
10356
+ static inputSchema() {
10357
+ return inputSchema50;
10358
+ }
10359
+ static outputSchema() {
10360
+ return outputSchema49;
10361
+ }
10362
+ async executeReactive(input2, _output, _context) {
10363
+ const { image, borderWidth: bw = 1, color } = input2;
10364
+ const { data: src, width: srcW, height: srcH, channels: srcCh } = image;
10365
+ const outCh = 4;
10366
+ const dstW = srcW + bw * 2;
10367
+ const dstH = srcH + bw * 2;
10368
+ const dst = new Uint8ClampedArray(dstW * dstH * outCh);
10369
+ const r = color.r;
10370
+ const g = color.g;
10371
+ const b = color.b;
10372
+ const a = color.a ?? 255;
10373
+ for (let i = 0;i < dst.length; i += outCh) {
10374
+ dst[i] = r;
10375
+ dst[i + 1] = g;
10376
+ dst[i + 2] = b;
10377
+ dst[i + 3] = a;
10378
+ }
10379
+ for (let y = 0;y < srcH; y++) {
10380
+ for (let x = 0;x < srcW; x++) {
10381
+ const srcIdx = (y * srcW + x) * srcCh;
10382
+ const dstIdx = ((y + bw) * dstW + (x + bw)) * outCh;
10383
+ dst[dstIdx] = src[srcIdx];
10384
+ dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
10385
+ dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
10386
+ dst[dstIdx + 3] = srcCh === 4 ? src[srcIdx + 3] : 255;
10387
+ }
10388
+ }
10389
+ return {
10390
+ image: { data: dst, width: dstW, height: dstH, channels: outCh }
10391
+ };
10392
+ }
10393
+ }
10394
+ Workflow58.prototype.imageBorder = CreateWorkflow57(ImageBorderTask);
10395
+ // src/task/image/ImageTransparencyTask.ts
10396
+ import {
10397
+ CreateWorkflow as CreateWorkflow58,
10398
+ Task as Task57,
10399
+ Workflow as Workflow59
10400
+ } from "@workglow/task-graph";
10401
+ var inputSchema51 = {
10402
+ type: "object",
10403
+ properties: {
10404
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10405
+ opacity: {
10406
+ type: "number",
10407
+ title: "Opacity",
10408
+ description: "Opacity level (0.0 = fully transparent, 1.0 = fully opaque)",
10409
+ minimum: 0,
10410
+ maximum: 1
10411
+ }
10412
+ },
10413
+ required: ["image", "opacity"],
10414
+ additionalProperties: false
10415
+ };
10416
+ var outputSchema50 = {
10417
+ type: "object",
10418
+ properties: {
10419
+ image: ImageBinarySchema({ title: "Image", description: "Image with adjusted transparency" })
10420
+ },
10421
+ required: ["image"],
10422
+ additionalProperties: false
10423
+ };
10424
+
10425
+ class ImageTransparencyTask extends Task57 {
10426
+ static type = "ImageTransparencyTask";
10427
+ static category = "Image";
10428
+ static title = "Set Transparency";
10429
+ static description = "Adjusts the opacity of an image";
10430
+ static inputSchema() {
10431
+ return inputSchema51;
10432
+ }
10433
+ static outputSchema() {
10434
+ return outputSchema50;
10435
+ }
10436
+ async executeReactive(input2, _output, _context) {
10437
+ const { image, opacity } = input2;
10438
+ const { data: src, width, height, channels: srcCh } = image;
10439
+ const pixelCount = width * height;
10440
+ const dst = new Uint8ClampedArray(pixelCount * 4);
10441
+ const alphaScale = Math.round(opacity * 255);
10442
+ for (let i = 0;i < pixelCount; i++) {
10443
+ const srcIdx = i * srcCh;
10444
+ const dstIdx = i * 4;
10445
+ dst[dstIdx] = src[srcIdx];
10446
+ dst[dstIdx + 1] = srcCh >= 3 ? src[srcIdx + 1] : src[srcIdx];
10447
+ dst[dstIdx + 2] = srcCh >= 3 ? src[srcIdx + 2] : src[srcIdx];
10448
+ const srcAlpha = srcCh === 4 ? src[srcIdx + 3] : 255;
10449
+ dst[dstIdx + 3] = (srcAlpha * alphaScale + 127) / 255;
10450
+ }
10451
+ return {
10452
+ image: { data: dst, width, height, channels: 4 }
10453
+ };
10454
+ }
10455
+ }
10456
+ Workflow59.prototype.imageTransparency = CreateWorkflow58(ImageTransparencyTask);
10457
+ // src/task/image/ImageBlurTask.ts
10458
+ import {
10459
+ CreateWorkflow as CreateWorkflow59,
10460
+ Task as Task58,
10461
+ Workflow as Workflow60
10462
+ } from "@workglow/task-graph";
10463
+ var inputSchema52 = {
10464
+ type: "object",
10465
+ properties: {
10466
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10467
+ radius: {
10468
+ type: "integer",
10469
+ title: "Radius",
10470
+ description: "Blur radius (1-10)",
10471
+ minimum: 1,
10472
+ maximum: 10,
10473
+ default: 1
10474
+ }
10475
+ },
10476
+ required: ["image"],
10477
+ additionalProperties: false
10478
+ };
10479
+ var outputSchema51 = {
10480
+ type: "object",
10481
+ properties: {
10482
+ image: ImageBinarySchema({ title: "Image", description: "Blurred image" })
10483
+ },
10484
+ required: ["image"],
10485
+ additionalProperties: false
10486
+ };
10487
+
10488
+ class ImageBlurTask extends Task58 {
10489
+ static type = "ImageBlurTask";
10490
+ static category = "Image";
10491
+ static title = "Blur Image";
10492
+ static description = "Applies a box blur to an image";
10493
+ static inputSchema() {
10494
+ return inputSchema52;
10495
+ }
10496
+ static outputSchema() {
10497
+ return outputSchema51;
10498
+ }
10499
+ async executeReactive(input2, _output, _context) {
10500
+ const { image, radius = 1 } = input2;
10501
+ const { data: src, width, height, channels } = image;
10502
+ const kernelSize = radius * 2 + 1;
10503
+ const tmp = new Uint8ClampedArray(src.length);
10504
+ for (let y = 0;y < height; y++) {
10505
+ for (let c = 0;c < channels; c++) {
10506
+ let sum = 0;
10507
+ for (let k = -radius;k <= radius; k++) {
10508
+ const x = Math.max(0, Math.min(k, width - 1));
10509
+ sum += src[(y * width + x) * channels + c];
10510
+ }
10511
+ tmp[y * width * channels + c] = sum / kernelSize + 0.5 | 0;
10512
+ for (let x = 1;x < width; x++) {
10513
+ const addX = Math.min(x + radius, width - 1);
10514
+ const removeX = Math.max(x - radius - 1, 0);
10515
+ sum += src[(y * width + addX) * channels + c] - src[(y * width + removeX) * channels + c];
10516
+ tmp[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
10517
+ }
10518
+ }
10519
+ }
10520
+ const dst = new Uint8ClampedArray(src.length);
10521
+ for (let x = 0;x < width; x++) {
10522
+ for (let c = 0;c < channels; c++) {
10523
+ let sum = 0;
10524
+ for (let k = -radius;k <= radius; k++) {
10525
+ const y = Math.max(0, Math.min(k, height - 1));
10526
+ sum += tmp[(y * width + x) * channels + c];
10527
+ }
10528
+ dst[x * channels + c] = sum / kernelSize + 0.5 | 0;
10529
+ for (let y = 1;y < height; y++) {
10530
+ const addY = Math.min(y + radius, height - 1);
10531
+ const removeY = Math.max(y - radius - 1, 0);
10532
+ sum += tmp[(addY * width + x) * channels + c] - tmp[(removeY * width + x) * channels + c];
10533
+ dst[(y * width + x) * channels + c] = sum / kernelSize + 0.5 | 0;
10534
+ }
10535
+ }
10536
+ }
10537
+ return { image: { data: dst, width, height, channels } };
10538
+ }
10539
+ }
10540
+ Workflow60.prototype.imageBlur = CreateWorkflow59(ImageBlurTask);
10541
+ // src/task/image/ImageWatermarkTask.ts
10542
+ import {
10543
+ CreateWorkflow as CreateWorkflow60,
10544
+ Task as Task59,
10545
+ Workflow as Workflow61
10546
+ } from "@workglow/task-graph";
10547
+ var inputSchema53 = {
10548
+ type: "object",
10549
+ properties: {
10550
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10551
+ spacing: {
10552
+ type: "integer",
10553
+ title: "Spacing",
10554
+ description: "Pattern spacing in pixels",
10555
+ minimum: 8,
10556
+ default: 64
10557
+ },
10558
+ opacity: {
10559
+ type: "number",
10560
+ title: "Opacity",
10561
+ description: "Watermark opacity (0.0-1.0)",
10562
+ minimum: 0,
10563
+ maximum: 1,
10564
+ default: 0.3
10565
+ },
10566
+ pattern: {
10567
+ type: "string",
10568
+ enum: ["diagonal-lines", "grid", "dots"],
10569
+ title: "Pattern",
10570
+ description: "Watermark pattern type",
10571
+ default: "diagonal-lines"
10572
+ }
10573
+ },
10574
+ required: ["image"],
10575
+ additionalProperties: false
10576
+ };
10577
+ var outputSchema52 = {
10578
+ type: "object",
10579
+ properties: {
10580
+ image: ImageBinarySchema({ title: "Image", description: "Watermarked image" })
10581
+ },
10582
+ required: ["image"],
10583
+ additionalProperties: false
10584
+ };
10585
+
10586
+ class ImageWatermarkTask extends Task59 {
10587
+ static type = "ImageWatermarkTask";
10588
+ static category = "Image";
10589
+ static title = "Add Watermark";
10590
+ static description = "Adds a repeating pattern watermark to an image";
10591
+ static inputSchema() {
10592
+ return inputSchema53;
10593
+ }
10594
+ static outputSchema() {
10595
+ return outputSchema52;
10596
+ }
10597
+ async executeReactive(input2, _output, _context) {
10598
+ const { image, spacing = 64, opacity = 0.3, pattern = "diagonal-lines" } = input2;
10599
+ const { data: src, width, height, channels: srcCh } = image;
10600
+ const outCh = 4;
10601
+ const dst = new Uint8ClampedArray(width * height * outCh);
10602
+ const lineWidth = 2;
10603
+ const dotRadius = Math.max(2, spacing >> 3);
10604
+ const dotRadiusSq = dotRadius * dotRadius;
10605
+ const half = spacing >> 1;
10606
+ const alpha = Math.round(opacity * 255);
10607
+ for (let y = 0;y < height; y++) {
10608
+ for (let x = 0;x < width; x++) {
10609
+ const srcIdx = (y * width + x) * srcCh;
10610
+ const dstIdx = (y * width + x) * outCh;
10611
+ const sr = src[srcIdx];
10612
+ const sg = srcCh >= 3 ? src[srcIdx + 1] : sr;
10613
+ const sb = srcCh >= 3 ? src[srcIdx + 2] : sr;
10614
+ const sa = srcCh === 4 ? src[srcIdx + 3] : 255;
10615
+ let isPattern = false;
10616
+ if (pattern === "diagonal-lines") {
10617
+ isPattern = (x + y) % spacing < lineWidth;
10618
+ } else if (pattern === "grid") {
10619
+ isPattern = x % spacing < lineWidth || y % spacing < lineWidth;
10620
+ } else {
10621
+ const dx = x % spacing - half;
10622
+ const dy = y % spacing - half;
10623
+ isPattern = dx * dx + dy * dy < dotRadiusSq;
10624
+ }
10625
+ if (isPattern) {
10626
+ const blend = alpha;
10627
+ const invBlend = 255 - blend;
10628
+ dst[dstIdx] = (sr * invBlend + 255 * blend + 127) / 255;
10629
+ dst[dstIdx + 1] = (sg * invBlend + 255 * blend + 127) / 255;
10630
+ dst[dstIdx + 2] = (sb * invBlend + 255 * blend + 127) / 255;
10631
+ dst[dstIdx + 3] = sa;
10632
+ } else {
10633
+ dst[dstIdx] = sr;
10634
+ dst[dstIdx + 1] = sg;
10635
+ dst[dstIdx + 2] = sb;
10636
+ dst[dstIdx + 3] = sa;
10637
+ }
10638
+ }
10639
+ }
10640
+ return {
10641
+ image: { data: dst, width, height, channels: outCh }
10642
+ };
10643
+ }
10644
+ }
10645
+ Workflow61.prototype.imageWatermark = CreateWorkflow60(ImageWatermarkTask);
10646
+ // src/task/image/ImagePixelateTask.ts
10647
+ import {
10648
+ CreateWorkflow as CreateWorkflow61,
10649
+ Task as Task60,
10650
+ Workflow as Workflow62
10651
+ } from "@workglow/task-graph";
10652
+ var inputSchema54 = {
10653
+ type: "object",
10654
+ properties: {
10655
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10656
+ blockSize: {
10657
+ type: "integer",
10658
+ title: "Block Size",
10659
+ description: "Size of each pixelation block",
10660
+ minimum: 2,
10661
+ default: 8
10662
+ }
10663
+ },
10664
+ required: ["image"],
10665
+ additionalProperties: false
10666
+ };
10667
+ var outputSchema53 = {
10668
+ type: "object",
10669
+ properties: {
10670
+ image: ImageBinarySchema({ title: "Image", description: "Pixelated image" })
10671
+ },
10672
+ required: ["image"],
10673
+ additionalProperties: false
10674
+ };
10675
+
10676
+ class ImagePixelateTask extends Task60 {
10677
+ static type = "ImagePixelateTask";
10678
+ static category = "Image";
10679
+ static title = "Pixelate Image";
10680
+ static description = "Pixelates an image by averaging blocks of pixels";
10681
+ static inputSchema() {
10682
+ return inputSchema54;
10683
+ }
10684
+ static outputSchema() {
10685
+ return outputSchema53;
10686
+ }
10687
+ async executeReactive(input2, _output, _context) {
10688
+ const { image, blockSize = 8 } = input2;
10689
+ const { data: src, width, height, channels } = image;
10690
+ const dst = new Uint8ClampedArray(src.length);
10691
+ for (let by = 0;by < height; by += blockSize) {
10692
+ const blockH = Math.min(blockSize, height - by);
10693
+ for (let bx = 0;bx < width; bx += blockSize) {
10694
+ const blockW = Math.min(blockSize, width - bx);
10695
+ const blockArea = blockW * blockH;
10696
+ const sums = new Array(channels).fill(0);
10697
+ for (let y = by;y < by + blockH; y++) {
10698
+ for (let x = bx;x < bx + blockW; x++) {
10699
+ const idx = (y * width + x) * channels;
10700
+ for (let c = 0;c < channels; c++) {
10701
+ sums[c] += src[idx + c];
10702
+ }
10703
+ }
10704
+ }
10705
+ const avg = sums.map((s) => s / blockArea + 0.5 | 0);
10706
+ for (let y = by;y < by + blockH; y++) {
10707
+ for (let x = bx;x < bx + blockW; x++) {
10708
+ const idx = (y * width + x) * channels;
10709
+ for (let c = 0;c < channels; c++) {
10710
+ dst[idx + c] = avg[c];
10711
+ }
10712
+ }
10713
+ }
10714
+ }
10715
+ }
10716
+ return { image: { data: dst, width, height, channels } };
10717
+ }
10718
+ }
10719
+ Workflow62.prototype.imagePixelate = CreateWorkflow61(ImagePixelateTask);
10720
+ // src/task/image/ImageInvertTask.ts
10721
+ import {
10722
+ CreateWorkflow as CreateWorkflow62,
10723
+ Task as Task61,
10724
+ Workflow as Workflow63
10725
+ } from "@workglow/task-graph";
10726
+ var inputSchema55 = {
10727
+ type: "object",
10728
+ properties: {
10729
+ image: ImageBinarySchema({ title: "Image", description: "Source image" })
10730
+ },
10731
+ required: ["image"],
10732
+ additionalProperties: false
10733
+ };
10734
+ var outputSchema54 = {
10735
+ type: "object",
10736
+ properties: {
10737
+ image: ImageBinarySchema({ title: "Image", description: "Inverted image" })
10738
+ },
10739
+ required: ["image"],
10740
+ additionalProperties: false
10741
+ };
10742
+
10743
+ class ImageInvertTask extends Task61 {
10744
+ static type = "ImageInvertTask";
10745
+ static category = "Image";
10746
+ static title = "Invert Colors";
10747
+ static description = "Inverts the colors of an image";
10748
+ static inputSchema() {
10749
+ return inputSchema55;
10750
+ }
10751
+ static outputSchema() {
10752
+ return outputSchema54;
10753
+ }
10754
+ async executeReactive(input2, _output, _context) {
10755
+ const { data: src, width, height, channels } = input2.image;
10756
+ const dst = new Uint8ClampedArray(src.length);
10757
+ if (channels === 4) {
10758
+ for (let i = 0;i < src.length; i += 4) {
10759
+ dst[i] = 255 - src[i];
10760
+ dst[i + 1] = 255 - src[i + 1];
10761
+ dst[i + 2] = 255 - src[i + 2];
10762
+ dst[i + 3] = src[i + 3];
10763
+ }
10764
+ } else {
10765
+ for (let i = 0;i < src.length; i++) {
10766
+ dst[i] = 255 - src[i];
10767
+ }
10768
+ }
10769
+ return { image: { data: dst, width, height, channels } };
10770
+ }
10771
+ }
10772
+ Workflow63.prototype.imageInvert = CreateWorkflow62(ImageInvertTask);
10773
+ // src/task/image/ImageBrightnessTask.ts
10774
+ import {
10775
+ CreateWorkflow as CreateWorkflow63,
10776
+ Task as Task62,
10777
+ Workflow as Workflow64
10778
+ } from "@workglow/task-graph";
10779
+ var inputSchema56 = {
10780
+ type: "object",
10781
+ properties: {
10782
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10783
+ amount: {
10784
+ type: "number",
10785
+ title: "Amount",
10786
+ description: "Brightness adjustment (-255 to 255)",
10787
+ minimum: -255,
10788
+ maximum: 255,
10789
+ default: 0
10790
+ }
10791
+ },
10792
+ required: ["image"],
10793
+ additionalProperties: false
10794
+ };
10795
+ var outputSchema55 = {
10796
+ type: "object",
10797
+ properties: {
10798
+ image: ImageBinarySchema({ title: "Image", description: "Brightness-adjusted image" })
10799
+ },
10800
+ required: ["image"],
10801
+ additionalProperties: false
10802
+ };
10803
+
10804
+ class ImageBrightnessTask extends Task62 {
10805
+ static type = "ImageBrightnessTask";
10806
+ static category = "Image";
10807
+ static title = "Adjust Brightness";
10808
+ static description = "Adjusts the brightness of an image";
10809
+ static inputSchema() {
10810
+ return inputSchema56;
10811
+ }
10812
+ static outputSchema() {
10813
+ return outputSchema55;
10814
+ }
10815
+ async executeReactive(input2, _output, _context) {
10816
+ const { data: src, width, height, channels } = input2.image;
10817
+ const amount = input2.amount ?? 0;
10818
+ const dst = new Uint8ClampedArray(src.length);
10819
+ if (channels === 4) {
10820
+ for (let i = 0;i < src.length; i += 4) {
10821
+ dst[i] = src[i] + amount;
10822
+ dst[i + 1] = src[i + 1] + amount;
10823
+ dst[i + 2] = src[i + 2] + amount;
10824
+ dst[i + 3] = src[i + 3];
10825
+ }
10826
+ } else {
10827
+ for (let i = 0;i < src.length; i++) {
10828
+ dst[i] = src[i] + amount;
10829
+ }
10830
+ }
10831
+ return { image: { data: dst, width, height, channels } };
10832
+ }
10833
+ }
10834
+ Workflow64.prototype.imageBrightness = CreateWorkflow63(ImageBrightnessTask);
10835
+ // src/task/image/ImageContrastTask.ts
10836
+ import {
10837
+ CreateWorkflow as CreateWorkflow64,
10838
+ Task as Task63,
10839
+ Workflow as Workflow65
10840
+ } from "@workglow/task-graph";
10841
+ var inputSchema57 = {
10842
+ type: "object",
10843
+ properties: {
10844
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10845
+ amount: {
10846
+ type: "number",
10847
+ title: "Amount",
10848
+ description: "Contrast adjustment (-100 to 100)",
10849
+ minimum: -100,
10850
+ maximum: 100,
10851
+ default: 0
10852
+ }
10853
+ },
10854
+ required: ["image"],
10855
+ additionalProperties: false
10856
+ };
10857
+ var outputSchema56 = {
10858
+ type: "object",
10859
+ properties: {
10860
+ image: ImageBinarySchema({ title: "Image", description: "Contrast-adjusted image" })
10861
+ },
10862
+ required: ["image"],
10863
+ additionalProperties: false
10864
+ };
10865
+
10866
+ class ImageContrastTask extends Task63 {
10867
+ static type = "ImageContrastTask";
10868
+ static category = "Image";
10869
+ static title = "Adjust Contrast";
10870
+ static description = "Adjusts the contrast of an image";
10871
+ static inputSchema() {
10872
+ return inputSchema57;
10873
+ }
10874
+ static outputSchema() {
10875
+ return outputSchema56;
10876
+ }
10877
+ async executeReactive(input2, _output, _context) {
10878
+ const { data: src, width, height, channels } = input2.image;
10879
+ const amount = input2.amount ?? 0;
10880
+ const factor = 259 * (amount + 255) / (255 * (259 - amount));
10881
+ const lut = new Uint8ClampedArray(256);
10882
+ for (let i = 0;i < 256; i++) {
10883
+ lut[i] = factor * (i - 128) + 128;
10884
+ }
10885
+ const dst = new Uint8ClampedArray(src.length);
10886
+ if (channels === 4) {
10887
+ for (let i = 0;i < src.length; i += 4) {
10888
+ dst[i] = lut[src[i]];
10889
+ dst[i + 1] = lut[src[i + 1]];
10890
+ dst[i + 2] = lut[src[i + 2]];
10891
+ dst[i + 3] = src[i + 3];
10892
+ }
10893
+ } else {
10894
+ for (let i = 0;i < src.length; i++) {
10895
+ dst[i] = lut[src[i]];
10896
+ }
10897
+ }
10898
+ return { image: { data: dst, width, height, channels } };
10899
+ }
10900
+ }
10901
+ Workflow65.prototype.imageContrast = CreateWorkflow64(ImageContrastTask);
10902
+ // src/task/image/ImageSepiaTask.ts
10903
+ import {
10904
+ CreateWorkflow as CreateWorkflow65,
10905
+ Task as Task64,
10906
+ Workflow as Workflow66
10907
+ } from "@workglow/task-graph";
10908
+ var inputSchema58 = {
10909
+ type: "object",
10910
+ properties: {
10911
+ image: ImageBinarySchema({ title: "Image", description: "Source image" })
10912
+ },
10913
+ required: ["image"],
10914
+ additionalProperties: false
10915
+ };
10916
+ var outputSchema57 = {
10917
+ type: "object",
10918
+ properties: {
10919
+ image: ImageBinarySchema({ title: "Image", description: "Sepia-toned image" })
10920
+ },
10921
+ required: ["image"],
10922
+ additionalProperties: false
10923
+ };
10924
+
10925
+ class ImageSepiaTask extends Task64 {
10926
+ static type = "ImageSepiaTask";
10927
+ static category = "Image";
10928
+ static title = "Sepia Tone";
10929
+ static description = "Applies a sepia tone filter to an image";
10930
+ static inputSchema() {
10931
+ return inputSchema58;
10932
+ }
10933
+ static outputSchema() {
10934
+ return outputSchema57;
10935
+ }
10936
+ async executeReactive(input2, _output, _context) {
10937
+ const { data: src, width, height, channels } = input2.image;
10938
+ const dst = new Uint8ClampedArray(src.length);
10939
+ const pixelCount = width * height;
10940
+ for (let i = 0;i < pixelCount; i++) {
10941
+ const idx = i * channels;
10942
+ const r = channels === 1 ? src[idx] : src[idx];
10943
+ const g = channels === 1 ? src[idx] : src[idx + 1];
10944
+ const b = channels === 1 ? src[idx] : src[idx + 2];
10945
+ const outR = r * 402 + g * 787 + b * 194 >> 10;
10946
+ const outG = r * 357 + g * 702 + b * 172 >> 10;
10947
+ const outB = r * 279 + g * 547 + b * 134 >> 10;
10948
+ dst[idx] = outR > 255 ? 255 : outR;
10949
+ if (channels >= 3) {
10950
+ dst[idx + 1] = outG > 255 ? 255 : outG;
10951
+ dst[idx + 2] = outB > 255 ? 255 : outB;
10952
+ }
10953
+ if (channels === 4) {
10954
+ dst[idx + 3] = src[idx + 3];
10955
+ }
10956
+ }
10957
+ return { image: { data: dst, width, height, channels } };
10958
+ }
10959
+ }
10960
+ Workflow66.prototype.imageSepia = CreateWorkflow65(ImageSepiaTask);
10961
+ // src/task/image/ImageThresholdTask.ts
10962
+ import {
10963
+ CreateWorkflow as CreateWorkflow66,
10964
+ Task as Task65,
10965
+ Workflow as Workflow67
10966
+ } from "@workglow/task-graph";
10967
+ var inputSchema59 = {
10968
+ type: "object",
10969
+ properties: {
10970
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
10971
+ threshold: {
10972
+ type: "integer",
10973
+ title: "Threshold",
10974
+ description: "Threshold value (0-255)",
10975
+ minimum: 0,
10976
+ maximum: 255,
10977
+ default: 128
10978
+ }
10979
+ },
10980
+ required: ["image"],
10981
+ additionalProperties: false
10982
+ };
10983
+ var outputSchema58 = {
10984
+ type: "object",
10985
+ properties: {
10986
+ image: ImageBinarySchema({ title: "Image", description: "Thresholded binary image" })
10987
+ },
10988
+ required: ["image"],
10989
+ additionalProperties: false
10990
+ };
10991
+
10992
+ class ImageThresholdTask extends Task65 {
10993
+ static type = "ImageThresholdTask";
10994
+ static category = "Image";
10995
+ static title = "Threshold";
10996
+ static description = "Converts an image to binary black and white";
10997
+ static inputSchema() {
10998
+ return inputSchema59;
10999
+ }
11000
+ static outputSchema() {
11001
+ return outputSchema58;
11002
+ }
11003
+ async executeReactive(input2, _output, _context) {
11004
+ const { data: src, width, height, channels } = input2.image;
11005
+ const threshold = input2.threshold ?? 128;
11006
+ const pixelCount = width * height;
11007
+ const dst = new Uint8ClampedArray(pixelCount);
11008
+ for (let i = 0;i < pixelCount; i++) {
11009
+ const idx = i * channels;
11010
+ let gray;
11011
+ if (channels === 1) {
11012
+ gray = src[idx];
11013
+ } else {
11014
+ gray = src[idx] * 77 + src[idx + 1] * 150 + src[idx + 2] * 29 >> 8;
11015
+ }
11016
+ dst[i] = gray >= threshold ? 255 : 0;
11017
+ }
11018
+ return { image: { data: dst, width, height, channels: 1 } };
11019
+ }
11020
+ }
11021
+ Workflow67.prototype.imageThreshold = CreateWorkflow66(ImageThresholdTask);
11022
+ // src/task/image/ImagePosterizeTask.ts
11023
+ import {
11024
+ CreateWorkflow as CreateWorkflow67,
11025
+ Task as Task66,
11026
+ Workflow as Workflow68
11027
+ } from "@workglow/task-graph";
11028
+ var inputSchema60 = {
11029
+ type: "object",
11030
+ properties: {
11031
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
11032
+ levels: {
11033
+ type: "integer",
11034
+ title: "Levels",
11035
+ description: "Number of color levels per channel (2-32)",
11036
+ minimum: 2,
11037
+ maximum: 32,
11038
+ default: 4
11039
+ }
11040
+ },
11041
+ required: ["image"],
11042
+ additionalProperties: false
11043
+ };
11044
+ var outputSchema59 = {
11045
+ type: "object",
11046
+ properties: {
11047
+ image: ImageBinarySchema({ title: "Image", description: "Posterized image" })
11048
+ },
11049
+ required: ["image"],
11050
+ additionalProperties: false
11051
+ };
11052
+
11053
+ class ImagePosterizeTask extends Task66 {
11054
+ static type = "ImagePosterizeTask";
11055
+ static category = "Image";
11056
+ static title = "Posterize";
11057
+ static description = "Reduces the number of color levels in an image";
11058
+ static inputSchema() {
11059
+ return inputSchema60;
11060
+ }
11061
+ static outputSchema() {
11062
+ return outputSchema59;
11063
+ }
11064
+ async executeReactive(input2, _output, _context) {
11065
+ const { data: src, width, height, channels } = input2.image;
11066
+ const levels = input2.levels ?? 4;
11067
+ const step = 255 / (levels - 1);
11068
+ const lut = new Uint8ClampedArray(256);
11069
+ for (let i = 0;i < 256; i++) {
11070
+ lut[i] = Math.round(Math.round(i / step) * step);
11071
+ }
11072
+ const dst = new Uint8ClampedArray(src.length);
11073
+ if (channels === 4) {
11074
+ for (let i = 0;i < src.length; i += 4) {
11075
+ dst[i] = lut[src[i]];
11076
+ dst[i + 1] = lut[src[i + 1]];
11077
+ dst[i + 2] = lut[src[i + 2]];
11078
+ dst[i + 3] = src[i + 3];
11079
+ }
11080
+ } else {
11081
+ for (let i = 0;i < src.length; i++) {
11082
+ dst[i] = lut[src[i]];
11083
+ }
11084
+ }
11085
+ return { image: { data: dst, width, height, channels } };
11086
+ }
11087
+ }
11088
+ Workflow68.prototype.imagePosterize = CreateWorkflow67(ImagePosterizeTask);
11089
+ // src/task/image/ImageTintTask.ts
11090
+ import {
11091
+ CreateWorkflow as CreateWorkflow68,
11092
+ Task as Task67,
11093
+ Workflow as Workflow69
11094
+ } from "@workglow/task-graph";
11095
+ var inputSchema61 = {
11096
+ type: "object",
11097
+ properties: {
11098
+ image: ImageBinarySchema({ title: "Image", description: "Source image" }),
11099
+ color: ColorSchema({ title: "Color", description: "Tint color" }),
11100
+ amount: {
11101
+ type: "number",
11102
+ title: "Amount",
11103
+ description: "Tint strength (0.0 = no tint, 1.0 = full tint color)",
11104
+ minimum: 0,
11105
+ maximum: 1,
11106
+ default: 0.5
11107
+ }
11108
+ },
11109
+ required: ["image", "color"],
11110
+ additionalProperties: false
11111
+ };
11112
+ var outputSchema60 = {
11113
+ type: "object",
11114
+ properties: {
11115
+ image: ImageBinarySchema({ title: "Image", description: "Tinted image" })
11116
+ },
11117
+ required: ["image"],
11118
+ additionalProperties: false
11119
+ };
11120
+
11121
+ class ImageTintTask extends Task67 {
11122
+ static type = "ImageTintTask";
11123
+ static category = "Image";
11124
+ static title = "Tint Image";
11125
+ static description = "Applies a color tint to an image";
11126
+ static inputSchema() {
11127
+ return inputSchema61;
11128
+ }
11129
+ static outputSchema() {
11130
+ return outputSchema60;
11131
+ }
11132
+ async executeReactive(input2, _output, _context) {
11133
+ const { data: src, width, height, channels } = input2.image;
11134
+ const { r: tr, g: tg, b: tb } = input2.color;
11135
+ const amount = input2.amount ?? 0.5;
11136
+ const invAmount = 1 - amount;
11137
+ const tintR = tr * amount;
11138
+ const tintG = tg * amount;
11139
+ const tintB = tb * amount;
11140
+ const pixelCount = width * height;
11141
+ if (channels === 1) {
11142
+ const dst2 = new Uint8ClampedArray(pixelCount * 3);
11143
+ for (let i = 0;i < pixelCount; i++) {
11144
+ const gray = src[i];
11145
+ dst2[i * 3] = gray * invAmount + tintR;
11146
+ dst2[i * 3 + 1] = gray * invAmount + tintG;
11147
+ dst2[i * 3 + 2] = gray * invAmount + tintB;
11148
+ }
11149
+ return { image: { data: dst2, width, height, channels: 3 } };
11150
+ }
11151
+ const dst = new Uint8ClampedArray(src.length);
11152
+ for (let i = 0;i < pixelCount; i++) {
11153
+ const idx = i * channels;
11154
+ dst[idx] = src[idx] * invAmount + tintR;
11155
+ dst[idx + 1] = src[idx + 1] * invAmount + tintG;
11156
+ dst[idx + 2] = src[idx + 2] * invAmount + tintB;
11157
+ if (channels === 4) {
11158
+ dst[idx + 3] = src[idx + 3];
11159
+ }
11160
+ }
11161
+ return { image: { data: dst, width, height, channels } };
11162
+ }
11163
+ }
11164
+ Workflow69.prototype.imageTint = CreateWorkflow68(ImageTintTask);
9948
11165
 
9949
11166
  // src/common.ts
9950
11167
  import { TaskRegistry } from "@workglow/task-graph";
@@ -10000,20 +11217,37 @@ var registerCommonTasks = () => {
10000
11217
  JsonPathTask,
10001
11218
  TemplateTask,
10002
11219
  DateFormatTask,
10003
- RegexTask
11220
+ RegexTask,
11221
+ ImageResizeTask,
11222
+ ImageCropTask,
11223
+ ImageRotateTask,
11224
+ ImageFlipTask,
11225
+ ImageGrayscaleTask,
11226
+ ImageBorderTask,
11227
+ ImageTransparencyTask,
11228
+ ImageBlurTask,
11229
+ ImageWatermarkTask,
11230
+ ImagePixelateTask,
11231
+ ImageInvertTask,
11232
+ ImageBrightnessTask,
11233
+ ImageContrastTask,
11234
+ ImageSepiaTask,
11235
+ ImageThresholdTask,
11236
+ ImagePosterizeTask,
11237
+ ImageTintTask
10004
11238
  ];
10005
11239
  tasks.map(TaskRegistry.registerTask);
10006
11240
  return tasks;
10007
11241
  };
10008
11242
  // src/task/FileLoaderTask.ts
10009
11243
  import {
10010
- CreateWorkflow as CreateWorkflow52,
10011
- Task as Task51,
11244
+ CreateWorkflow as CreateWorkflow69,
11245
+ Task as Task68,
10012
11246
  TaskAbortedError as TaskAbortedError4,
10013
- Workflow as Workflow53
11247
+ Workflow as Workflow70
10014
11248
  } from "@workglow/task-graph";
10015
11249
  import Papa from "papaparse";
10016
- var inputSchema45 = {
11250
+ var inputSchema62 = {
10017
11251
  type: "object",
10018
11252
  properties: {
10019
11253
  url: {
@@ -10033,7 +11267,7 @@ var inputSchema45 = {
10033
11267
  required: ["url"],
10034
11268
  additionalProperties: false
10035
11269
  };
10036
- var outputSchema44 = {
11270
+ var outputSchema61 = {
10037
11271
  type: "object",
10038
11272
  properties: {
10039
11273
  text: {
@@ -10084,17 +11318,17 @@ var outputSchema44 = {
10084
11318
  additionalProperties: false
10085
11319
  };
10086
11320
 
10087
- class FileLoaderTask extends Task51 {
11321
+ class FileLoaderTask extends Task68 {
10088
11322
  static type = "FileLoaderTask";
10089
11323
  static category = "Document";
10090
11324
  static title = "File Loader";
10091
11325
  static description = "Load documents from URLs (http://, https://)";
10092
11326
  static cacheable = true;
10093
11327
  static inputSchema() {
10094
- return inputSchema45;
11328
+ return inputSchema62;
10095
11329
  }
10096
11330
  static outputSchema() {
10097
- return outputSchema44;
11331
+ return outputSchema61;
10098
11332
  }
10099
11333
  async execute(input2, context) {
10100
11334
  const { url, format = "auto" } = input2;
@@ -10446,7 +11680,7 @@ class FileLoaderTask extends Task51 {
10446
11680
  var fileLoader = (input2, config) => {
10447
11681
  return new FileLoaderTask(config).run(input2);
10448
11682
  };
10449
- Workflow53.prototype.fileLoader = CreateWorkflow52(FileLoaderTask);
11683
+ Workflow70.prototype.fileLoader = CreateWorkflow69(FileLoaderTask);
10450
11684
  // src/browser.ts
10451
11685
  import { TaskRegistry as TaskRegistry2 } from "@workglow/task-graph";
10452
11686
  registerMcpTaskDeps({
@@ -10554,6 +11788,25 @@ export {
10554
11788
  JavaScriptTask,
10555
11789
  InputTask,
10556
11790
  InMemoryMcpServerRepository,
11791
+ ImageWatermarkTask,
11792
+ ImageTransparencyTask,
11793
+ ImageTintTask,
11794
+ ImageThresholdTask,
11795
+ ImageSepiaTask,
11796
+ ImageRotateTask,
11797
+ ImageResizeTask,
11798
+ ImagePosterizeTask,
11799
+ ImagePixelateTask,
11800
+ ImageInvertTask,
11801
+ ImageGrayscaleTask,
11802
+ ImageFlipTask,
11803
+ ImageCropTask,
11804
+ ImageContrastTask,
11805
+ ImageBrightnessTask,
11806
+ ImageBorderTask,
11807
+ ImageBlurTask,
11808
+ ImageBinarySchemaOptions,
11809
+ ImageBinarySchema,
10557
11810
  HumanInputTask,
10558
11811
  HumanApprovalTask,
10559
11812
  HUMAN_CONNECTOR,
@@ -10564,7 +11817,8 @@ export {
10564
11817
  DebugLogTask,
10565
11818
  DateFormatTask,
10566
11819
  CredentialStoreOAuthProvider,
11820
+ ColorSchema,
10567
11821
  ArrayTask
10568
11822
  };
10569
11823
 
10570
- //# debugId=BE3950255C768C0964756E2164756E21
11824
+ //# debugId=BBCE6DDFCFAA6CF364756E2164756E21