@pixerate/editor 0.130.0 → 0.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/animation-editor/index.cjs +55 -55
  2. package/dist/animation-editor/index.d.cts +4 -4
  3. package/dist/animation-editor/index.d.ts +4 -4
  4. package/dist/animation-editor/index.js +2 -2
  5. package/dist/{bezier-CigmusV_.d.ts → bezier-BAGdL89w.d.ts} +1 -1
  6. package/dist/{bezier-CdoGygwG.d.cts → bezier-DL2wPsFf.d.cts} +1 -1
  7. package/dist/canvas/index.d.cts +7 -7
  8. package/dist/canvas/index.d.ts +7 -7
  9. package/dist/{chunk-MZXQTKUM.cjs → chunk-24ATT2PE.cjs} +10 -6
  10. package/dist/chunk-24ATT2PE.cjs.map +1 -0
  11. package/dist/{chunk-AHUYMDYW.js → chunk-2HC4DRF4.js} +10 -6
  12. package/dist/chunk-2HC4DRF4.js.map +1 -0
  13. package/dist/{chunk-2PXRKMOH.cjs → chunk-2QKUD3E2.cjs} +36 -36
  14. package/dist/{chunk-2PXRKMOH.cjs.map → chunk-2QKUD3E2.cjs.map} +1 -1
  15. package/dist/{chunk-PMHPXCJC.cjs → chunk-65GNHOD4.cjs} +268 -199
  16. package/dist/chunk-65GNHOD4.cjs.map +1 -0
  17. package/dist/{chunk-YRZ6NVE3.js → chunk-6CTZAGZ2.js} +235 -4
  18. package/dist/chunk-6CTZAGZ2.js.map +1 -0
  19. package/dist/{chunk-ERYGCA72.js → chunk-AOCFL7L7.js} +88 -19
  20. package/dist/chunk-AOCFL7L7.js.map +1 -0
  21. package/dist/{chunk-LXGOYRPE.cjs → chunk-F7GGEAO2.cjs} +322 -75
  22. package/dist/chunk-F7GGEAO2.cjs.map +1 -0
  23. package/dist/{chunk-PRYMC442.js → chunk-FOBB6AIO.js} +257 -10
  24. package/dist/chunk-FOBB6AIO.js.map +1 -0
  25. package/dist/{chunk-W6M7C7R3.cjs → chunk-NVTHUPJ6.cjs} +236 -5
  26. package/dist/chunk-NVTHUPJ6.cjs.map +1 -0
  27. package/dist/{chunk-L5OTIYOO.js → chunk-VGZSIXX3.js} +2 -2
  28. package/dist/effects/index.d.cts +4 -4
  29. package/dist/effects/index.d.ts +4 -4
  30. package/dist/{export-CejjC2iI.d.cts → export-BICOEM9d.d.cts} +33 -11
  31. package/dist/{export-5WDKJqTy.d.cts → export-CeFplzAW.d.cts} +1 -1
  32. package/dist/{export-B4r8b9Ft.d.ts → export-XnuX8FZ2.d.ts} +33 -11
  33. package/dist/{export-CU_ARP3A.d.ts → export-zB4HITwP.d.ts} +1 -1
  34. package/dist/{helpers-CzZu51eI.d.cts → helpers-BuKdqUlM.d.cts} +56 -1
  35. package/dist/{helpers-X_rycLNJ.d.ts → helpers-cssRNUzH.d.ts} +56 -1
  36. package/dist/image-editor/index.cjs +1064 -903
  37. package/dist/image-editor/index.cjs.map +1 -1
  38. package/dist/image-editor/index.d.cts +32 -13
  39. package/dist/image-editor/index.d.ts +32 -13
  40. package/dist/image-editor/index.js +180 -19
  41. package/dist/image-editor/index.js.map +1 -1
  42. package/dist/index.cjs +11 -4
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.js +11 -4
  45. package/dist/index.js.map +1 -1
  46. package/dist/{opentype-DlRMYcCW.d.cts → opentype-C3iyIFRx.d.cts} +1 -1
  47. package/dist/{opentype-CrHAsKh3.d.ts → opentype-DG5Lkwul.d.ts} +1 -1
  48. package/dist/paint/index.cjs +8 -2
  49. package/dist/paint/index.cjs.map +1 -1
  50. package/dist/paint/index.d.cts +14 -3
  51. package/dist/paint/index.d.ts +14 -3
  52. package/dist/paint/index.js +7 -1
  53. package/dist/paint-editor/index.cjs +78 -78
  54. package/dist/paint-editor/index.d.cts +7 -7
  55. package/dist/paint-editor/index.d.ts +7 -7
  56. package/dist/paint-editor/index.js +3 -3
  57. package/dist/{pathfinder-CKfKOVP4.d.cts → pathfinder-8vXik95z.d.cts} +1 -1
  58. package/dist/{pathfinder-Dlss70hL.d.ts → pathfinder-DKLt4UDG.d.ts} +1 -1
  59. package/dist/{pool-DDOo0xJH.d.ts → pool-C69pkWRz.d.ts} +1 -1
  60. package/dist/{pool-DKic69LD.d.cts → pool-VAWcYUbs.d.cts} +1 -1
  61. package/dist/{rand-pQQ2sJTk.d.ts → rand-BaqEOs1Y.d.ts} +17 -4
  62. package/dist/{rand-DTXAssW1.d.cts → rand-DdpFzCo6.d.cts} +17 -4
  63. package/dist/raster/index.cjs +2 -2
  64. package/dist/raster/index.d.cts +4 -4
  65. package/dist/raster/index.d.ts +4 -4
  66. package/dist/raster/index.js +1 -1
  67. package/dist/{svg-BRaii3pI.d.cts → svg-BThlZmja.d.cts} +2 -2
  68. package/dist/{svg-BYVZeVo0.d.ts → svg-CEYpvsgH.d.ts} +2 -2
  69. package/dist/{tools-CtheDLDr.d.cts → tools-CRnZJXXr.d.cts} +1 -1
  70. package/dist/{tools-D8bZ-7YG.d.ts → tools-CVGqEpO8.d.ts} +1 -1
  71. package/dist/vector/index.cjs +1493 -1032
  72. package/dist/vector/index.cjs.map +1 -1
  73. package/dist/vector/index.d.cts +155 -12
  74. package/dist/vector/index.d.ts +155 -12
  75. package/dist/vector/index.js +469 -8
  76. package/dist/vector/index.js.map +1 -1
  77. package/dist/video-editor/index.d.cts +4 -4
  78. package/dist/video-editor/index.d.ts +4 -4
  79. package/dist/{warp-BFoYxy_s.d.cts → warp-ChcFDdlT.d.cts} +1 -1
  80. package/dist/{warp-CZVC8pB5.d.ts → warp-mKylbLiF.d.ts} +1 -1
  81. package/package.json +2 -2
  82. package/skills/pixerate-image-editor/SKILL.md +7 -3
  83. package/skills/pixerate-image-editor/references/color-management.md +1 -1
  84. package/skills/pixerate-image-editor/references/photoshop-files.md +2 -2
  85. package/skills/pixerate-image-editor/references/retouching.md +12 -3
  86. package/skills/pixerate-vector/SKILL.md +17 -0
  87. package/skills/pixerate-vector/references/commands.md +19 -0
  88. package/dist/chunk-AHUYMDYW.js.map +0 -1
  89. package/dist/chunk-ERYGCA72.js.map +0 -1
  90. package/dist/chunk-LXGOYRPE.cjs.map +0 -1
  91. package/dist/chunk-MZXQTKUM.cjs.map +0 -1
  92. package/dist/chunk-PMHPXCJC.cjs.map +0 -1
  93. package/dist/chunk-PRYMC442.js.map +0 -1
  94. package/dist/chunk-W6M7C7R3.cjs.map +0 -1
  95. package/dist/chunk-YRZ6NVE3.js.map +0 -1
  96. /package/dist/{chunk-L5OTIYOO.js.map → chunk-VGZSIXX3.js.map} +0 -0
@@ -37,7 +37,7 @@ import {
37
37
  validateEffectGradient,
38
38
  validateLayerEffects,
39
39
  warpSurface
40
- } from "./chunk-AHUYMDYW.js";
40
+ } from "./chunk-2HC4DRF4.js";
41
41
  import {
42
42
  affineFromHomography,
43
43
  applyHomography,
@@ -66,8 +66,6 @@ import {
66
66
  surfaceFromPixels,
67
67
  tileKey,
68
68
  tilesInRect,
69
- to32From8,
70
- to8From32,
71
69
  translateSurface,
72
70
  writeDeepRegion
73
71
  } from "./chunk-BR7EKQUP.js";
@@ -125,7 +123,7 @@ import {
125
123
  textRectPath,
126
124
  translateMatrix,
127
125
  warpPresetMesh
128
- } from "./chunk-PRYMC442.js";
126
+ } from "./chunk-FOBB6AIO.js";
129
127
  import {
130
128
  bezierPathBounds,
131
129
  outlineStroke,
@@ -2085,6 +2083,52 @@ function applyLegacyAdjustments(imageData, adjustments) {
2085
2083
  }
2086
2084
  }
2087
2085
  }
2086
+ function applyLegacyFloat(data, adjustments, linear) {
2087
+ const { brightness, contrast, saturation, exposure, temperature } = adjustments;
2088
+ if (!brightness && !contrast && !saturation && !exposure && !temperature) return;
2089
+ const k = 259 * (contrast + 255) / (255 * (259 - contrast));
2090
+ const ex = Math.pow(2, exposure / 50);
2091
+ const sat = 1 + saturation / 100;
2092
+ const temp = temperature * 0.8;
2093
+ const cl = (v) => v < 0 ? 0 : v > 255 ? 255 : v;
2094
+ const enc = (v) => v <= 0 ? 0 : v >= 1 ? 1 : v <= 31308e-7 ? v * 12.92 : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
2095
+ const dec = (v) => v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
2096
+ for (let i = 0; i < data.length; i += 4) {
2097
+ if (!(data[i + 3] > 0)) continue;
2098
+ let r = (linear ? enc(data[i]) : data[i]) * 255;
2099
+ let g = (linear ? enc(data[i + 1]) : data[i + 1]) * 255;
2100
+ let b = (linear ? enc(data[i + 2]) : data[i + 2]) * 255;
2101
+ if (exposure) {
2102
+ r = cl(r * ex);
2103
+ g = cl(g * ex);
2104
+ b = cl(b * ex);
2105
+ }
2106
+ if (brightness) {
2107
+ const o = brightness * 2.55;
2108
+ r = cl(r + o);
2109
+ g = cl(g + o);
2110
+ b = cl(b + o);
2111
+ }
2112
+ if (contrast) {
2113
+ r = cl(k * (r - 128) + 128);
2114
+ g = cl(k * (g - 128) + 128);
2115
+ b = cl(k * (b - 128) + 128);
2116
+ }
2117
+ if (saturation) {
2118
+ const l = 0.2989 * r + 0.587 * g + 0.114 * b;
2119
+ r = cl(l + (r - l) * sat);
2120
+ g = cl(l + (g - l) * sat);
2121
+ b = cl(l + (b - l) * sat);
2122
+ }
2123
+ if (temperature) {
2124
+ r = cl(r + temp);
2125
+ b = cl(b - temp);
2126
+ }
2127
+ data[i] = linear ? dec(r / 255) : r / 255;
2128
+ data[i + 1] = linear ? dec(g / 255) : g / 255;
2129
+ data[i + 2] = linear ? dec(b / 255) : b / 255;
2130
+ }
2131
+ }
2088
2132
  var DECODE_LUT = (() => {
2089
2133
  const lut = new Float32Array(256);
2090
2134
  for (let i = 0; i < 256; i++) lut[i] = srgbToLinear(i / 255);
@@ -2454,12 +2498,7 @@ function runLayerFiltersFloat(data, width, height, filters, linear) {
2454
2498
  else if (f.kind === "develop") {
2455
2499
  const adj = developAdjustments(f);
2456
2500
  if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Float(data, adj, linear);
2457
- else {
2458
- const bytes = linear ? to8From32(data, 4) : Uint8ClampedArray.from(data, (v) => v * 255);
2459
- applyLegacyAdjustments({ data: bytes }, adj);
2460
- if (linear) data.set(to32From8(bytes, 4));
2461
- else for (let i = 0; i < data.length; i++) data[i] = bytes[i] / 255;
2462
- }
2501
+ else applyLegacyFloat(data, adj, linear);
2463
2502
  }
2464
2503
  }
2465
2504
  }
@@ -9359,6 +9398,16 @@ function toRgbaDeep(set) {
9359
9398
  };
9360
9399
  const planes = set.color.map((p) => raw(p, cmyk ? 1 : 0));
9361
9400
  const alpha = raw(set.alpha, 1);
9401
+ if (depth === 16 && cmyk && set.cmykToRgb16) {
9402
+ const ink = new Uint16Array(n * 4);
9403
+ const out2 = new Uint16Array(n * 4);
9404
+ for (let i = 0, o = 0; i < n; i++, o += 4) {
9405
+ for (let c = 0; c < 4; c++) ink[o + c] = Math.round((1 - (planes[c] ? planes[c](i) : 1)) * 65535);
9406
+ out2[o + 3] = Math.round(clamp012(alpha(i)) * 65535);
9407
+ }
9408
+ set.cmykToRgb16(ink, out2);
9409
+ return out2;
9410
+ }
9362
9411
  if (depth === 16) {
9363
9412
  const out2 = new Uint16Array(n * 4);
9364
9413
  const q2 = (v) => Math.round(clamp012(v) * 65535);
@@ -9752,9 +9801,10 @@ function recordPixels(ctx, rec, name) {
9752
9801
  color: planes.slice(0, ctx.colorCount),
9753
9802
  alpha: planes[ctx.colorCount],
9754
9803
  palette: ctx.palette,
9755
- cmykToRgb: ctx.cmykToRgb
9804
+ cmykToRgb: ctx.cmykToRgb,
9805
+ cmykToRgb16: ctx.cmykToRgb16
9756
9806
  };
9757
- const deep = set.cmykToRgb ? null : toRgbaDeep(set);
9807
+ const deep = set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
9758
9808
  if (deep) return surfaceFromDeepPixels({ width, height, data: deep }, 4, rec.rect.left, rec.rect.top);
9759
9809
  return surfaceFromPixels({ width, height, data: toRgba8(set) }, 4, rec.rect.left, rec.rect.top);
9760
9810
  }
@@ -9772,7 +9822,7 @@ function recordMask(ctx, rec, name) {
9772
9822
  if (width && height && !ctx.skipPixels) {
9773
9823
  const plane = decodeOr(ctx, rec, id, name);
9774
9824
  const depth = ctx.file.header.depth;
9775
- if (plane && (depth === 16 || depth === 32) && ctx.file.header.colorMode !== MODE_CMYK) surface = surfaceFromDeepPixels({ width, height, data: toMaskDeep(plane, width, height, depth) }, 1, rect.left, rect.top, def);
9825
+ if (plane && (depth === 16 || depth === 32)) surface = surfaceFromDeepPixels({ width, height, data: toMaskDeep(plane, width, height, depth) }, 1, rect.left, rect.top, def);
9776
9826
  else if (plane) surface = surfaceFromPixels({ width, height, data: toMask8(plane, width, height, depth) }, 1, rect.left, rect.top, def);
9777
9827
  }
9778
9828
  const mask = { surface, defaultValue: def };
@@ -10164,9 +10214,10 @@ function mergedLayer(ctx) {
10164
10214
  color: Array.from({ length: cc }, (_, i) => plane(i)),
10165
10215
  alpha: hasAlpha ? plane(cc) : void 0,
10166
10216
  palette: ctx.palette,
10167
- cmykToRgb: ctx.cmykToRgb
10217
+ cmykToRgb: ctx.cmykToRgb,
10218
+ cmykToRgb16: ctx.cmykToRgb16
10168
10219
  };
10169
- const deep = hasAlpha || set.cmykToRgb ? null : toRgbaDeep(set);
10220
+ const deep = hasAlpha || set.cmykToRgb && !set.cmykToRgb16 ? null : toRgbaDeep(set);
10170
10221
  let surface;
10171
10222
  if (deep) surface = surfaceFromDeepPixels({ width, height, data: deep }, 4);
10172
10223
  else {
@@ -10225,6 +10276,7 @@ function psdToLayers(file, options = {}) {
10225
10276
  }
10226
10277
  const t = Transform.create(src, srgbProfile(), { intent: "relative", bpc: true });
10227
10278
  ctx.cmykToRgb = (ink, out) => t.convert8(ink, 4, out, 4, false);
10279
+ if (header.depth === 16) ctx.cmykToRgb16 = (ink, out) => t.convert16(ink, 4, out, 4, false);
10228
10280
  }
10229
10281
  for (const block of file.globalBlocks) {
10230
10282
  if (LINKED_FILE_KEYS.includes(block.key)) {
@@ -11091,7 +11143,8 @@ function exportPsd(input) {
11091
11143
  if (width < 1 || height < 1) throw new PsdError("The document is empty.");
11092
11144
  const mode = input.colorMode ?? "rgb";
11093
11145
  if (mode !== "rgb" && !input.colorPlanes) throw new PsdError(`A ${mode.toUpperCase()} file needs colorPlanes to convert the pixels.`);
11094
- if (mode !== "rgb" && depth !== 8) throw new PsdError(`${mode.toUpperCase()} files are written at 8 bits per channel.`);
11146
+ if (mode !== "rgb" && depth === 32) throw new PsdError(`${mode.toUpperCase()} files are written at 8 or 16 bits per channel.`);
11147
+ if (mode !== "rgb" && depth === 16 && !input.colorPlanes16) throw new PsdError(`A 16-bit ${mode.toUpperCase()} file needs colorPlanes16 to convert the pixels.`);
11095
11148
  const colorIds = mode === "cmyk" ? [0, 1, 2, 3] : [0, 1, 2];
11096
11149
  const colorPlanes = (rgba, n2) => mode === "rgb" ? rgbaToPlanes(rgba, n2).slice(0, 3) : input.colorPlanes(rgba, n2);
11097
11150
  const pixelChannels = (rgba, w, h) => {
@@ -11100,6 +11153,14 @@ function exportPsd(input) {
11100
11153
  return [rleChannel(CHANNEL_ALPHA, alpha, w, h, psb), ...colorPlanes(rgba, n2).map((p, i) => rleChannel(i, p, w, h, psb))];
11101
11154
  };
11102
11155
  const surfaceChannels = (surface, bounds) => {
11156
+ if (mode !== "rgb" && depth === 16) {
11157
+ const n2 = bounds.width * bounds.height;
11158
+ const s = readDeepRegion(surface, bounds, 16);
11159
+ const alpha = new Uint16Array(n2);
11160
+ for (let i = 0; i < n2; i++) alpha[i] = s[i * 4 + 3];
11161
+ const planes2 = [alpha, ...input.colorPlanes16(s, n2)];
11162
+ return [CHANNEL_ALPHA, ...colorIds].map((id, i) => rleChannel(id, deepMaskPlane(planes2[i]), bounds.width, bounds.height, psb, 16));
11163
+ }
11103
11164
  if (mode !== "rgb") return pixelChannels(readRegion(surface, bounds), bounds.width, bounds.height);
11104
11165
  const [r, g, b, a2] = surfacePlanes(surface, bounds, depth);
11105
11166
  return [CHANNEL_ALPHA, 0, 1, 2].map((id, i) => rleChannel(id, [a2, r, g, b][i], bounds.width, bounds.height, psb, depth));
@@ -11304,8 +11365,15 @@ function exportPsd(input) {
11304
11365
  let planes = [...colorPlanes(matted, n), ...transparent ? [a] : []].map((p) => planeAtDepth(p, depth));
11305
11366
  const deep = input.mergedDeep;
11306
11367
  if (deep && depth !== 8 && deep.length >= n * 4 && (deep instanceof Uint16Array ? depth === 16 : depth === 32)) {
11307
- const dp = deepToPlanes(matteWhiteDeep(deep), n);
11308
- planes = transparent ? dp : dp.slice(0, 3);
11368
+ const mattedDeep = matteWhiteDeep(deep);
11369
+ if (mode !== "rgb" && mattedDeep instanceof Uint16Array) {
11370
+ const alpha = new Uint16Array(n);
11371
+ for (let i = 0; i < n; i++) alpha[i] = mattedDeep[i * 4 + 3];
11372
+ planes = [...input.colorPlanes16(mattedDeep, n), ...transparent ? [alpha] : []].map(deepMaskPlane);
11373
+ } else {
11374
+ const dp = deepToPlanes(mattedDeep, n);
11375
+ planes = transparent ? dp : dp.slice(0, 3);
11376
+ }
11309
11377
  }
11310
11378
  const planeBytes = n * (depth >> 3);
11311
11379
  const merged2 = new Uint8Array(planeBytes * planes.length);
@@ -11507,6 +11575,7 @@ export {
11507
11575
  adjustmentLayersKey,
11508
11576
  applyAdjustments,
11509
11577
  applyLegacyAdjustments,
11578
+ applyLegacyFloat,
11510
11579
  applyProcess2Adjustments,
11511
11580
  applyProcess2Float,
11512
11581
  applyBoxBlurFloat,
@@ -11736,4 +11805,4 @@ export {
11736
11805
  smartContentsFile,
11737
11806
  exportPsd
11738
11807
  };
11739
- //# sourceMappingURL=chunk-ERYGCA72.js.map
11808
+ //# sourceMappingURL=chunk-AOCFL7L7.js.map