ag-psd 25.0.0 → 26.0.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 (45) hide show
  1. package/.v8-cache/v22.13.1-x64-00250a7c/4511bacf +0 -0
  2. package/.v8-cache/v22.13.1-x64-00250a7c/acc36e66 +0 -0
  3. package/.v8-cache/v22.13.1-x64-00250a7c/b3c2fab7 +0 -0
  4. package/.v8-cache/v22.13.1-x64-00250a7c/c314aece +0 -0
  5. package/.v8-cache/v22.13.1-x64-00250a7c/cfc49f4f +0 -0
  6. package/.v8-cache/v22.13.1-x64-00250a7c/e03e2acd +0 -0
  7. package/CHANGELOG.md +3 -0
  8. package/{TODO → TODO.md} +46 -0
  9. package/dist/additionalInfo.js +55 -51
  10. package/dist/additionalInfo.js.map +1 -1
  11. package/dist/bundle.js +207 -159
  12. package/dist/descriptor.js +4 -4
  13. package/dist/descriptor.js.map +1 -1
  14. package/dist/helpers.d.ts +1 -0
  15. package/dist/helpers.js.map +1 -1
  16. package/dist/imageResources.js +39 -5
  17. package/dist/imageResources.js.map +1 -1
  18. package/dist/psd.d.ts +1 -0
  19. package/dist/psd.js.map +1 -1
  20. package/dist/psdReader.js +29 -31
  21. package/dist/psdReader.js.map +1 -1
  22. package/dist/psdWriter.js +79 -67
  23. package/dist/psdWriter.js.map +1 -1
  24. package/dist-es/additionalInfo.js +55 -51
  25. package/dist-es/additionalInfo.js.map +1 -1
  26. package/dist-es/descriptor.js +4 -4
  27. package/dist-es/descriptor.js.map +1 -1
  28. package/dist-es/helpers.d.ts +1 -0
  29. package/dist-es/helpers.js.map +1 -1
  30. package/dist-es/imageResources.js +41 -7
  31. package/dist-es/imageResources.js.map +1 -1
  32. package/dist-es/psd.d.ts +1 -0
  33. package/dist-es/psd.js.map +1 -1
  34. package/dist-es/psdReader.js +29 -31
  35. package/dist-es/psdReader.js.map +1 -1
  36. package/dist-es/psdWriter.js +79 -67
  37. package/dist-es/psdWriter.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/additionalInfo.ts +55 -51
  40. package/src/descriptor.ts +5 -4
  41. package/src/helpers.ts +1 -0
  42. package/src/imageResources.ts +46 -20
  43. package/src/psd.ts +1 -0
  44. package/src/psdReader.ts +32 -34
  45. package/src/psdWriter.ts +75 -69
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v26.0.0
4
+ - Added support for `realMask` section
5
+
3
6
  ## v25.0.0
4
7
  - Added support for `blendingRanges` section
5
8
  - Added support for `interpolationMethod` for gradients
@@ -25,6 +25,7 @@ check: https://github.com/TheNicker/libpsd
25
25
 
26
26
  - decompress image data in FEid section
27
27
 
28
+ ```ts
28
29
  if (!channelLength) throw new Error('filterEffect: Empty channel');
29
30
  const compression = readUint16(reader);
30
31
  const data = createImageDataBitDepth(right - left, bottom - top, depth, 1);
@@ -43,4 +44,49 @@ check: https://github.com/TheNicker/libpsd
43
44
  const data = createImageDataBitDepth(right - left, bottom - top, depth, 1);
44
45
  readData(reader, extraLength - 2, data, compression, data.width, data.height, depth, 0, false, 1);
45
46
  target.filterEffectsMasks[target.filterEffectsMasks.length - 1].extra = { top, left, bottom, right, data };
47
+ ```
46
48
 
49
+ ```ts
50
+ export function decodeUtf16String(buffer: Uint8Array) {
51
+ let result = '';
52
+
53
+ for (let i = 0; i < buffer.byteLength;) {
54
+ const w1 = (buffer[i++] << 8) | buffer[i++];
55
+
56
+ if ((w1 & 0xF800) !== 0xD800) { // w1 < 0xD800 || w1 > 0xDFFF
57
+ result += String.fromCharCode(w1);
58
+ continue;
59
+ }
60
+
61
+ if ((w1 & 0xFC00) === 0xD800) { // w1 >= 0xD800 && w1 <= 0xDBFF
62
+ throw new Error('Invalid utf-16');
63
+ }
64
+
65
+ if (i === buffer.byteLength) {
66
+ throw new Error('Invalid utf-16');
67
+ }
68
+
69
+ const w2 = (buffer[i++] << 8) | buffer[i++];
70
+
71
+ if ((w2 & 0xFC00) !== 0xDC00) { // w2 < 0xDC00 || w2 > 0xDFFF)
72
+ throw new Error('Invalid utf-16');
73
+ }
74
+
75
+ result += String.fromCharCode(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
76
+ }
77
+
78
+ return result;
79
+ }
80
+
81
+ export function encodeUtf16String(value: string) {
82
+ const buffer = new Uint8Array(value.length * 2);
83
+
84
+ for (let i = 0, j = 0; i < value.length; i++, j += 2) {
85
+ const word = value.charCodeAt(i);
86
+ buffer[j] = (word >> 8) & 0xff;
87
+ buffer[j + 1] = word & 0xff;
88
+ }
89
+
90
+ return buffer;
91
+ }
92
+ ```
@@ -339,58 +339,55 @@ addHandler('vogk', hasKey('vectorOrigination'), function (reader, target, left)
339
339
  var desc = { keyDescriptorList: [] };
340
340
  for (var i = 0; i < orig.keyDescriptorList.length; i++) {
341
341
  var item = orig.keyDescriptorList[i];
342
- if (item.keyShapeInvalidated) {
343
- desc.keyDescriptorList.push({ keyShapeInvalidated: true, keyOriginIndex: i });
342
+ desc.keyDescriptorList.push({}); // we're adding keyOriginIndex at the end
343
+ var out = desc.keyDescriptorList[desc.keyDescriptorList.length - 1];
344
+ if (item.keyOriginType != null)
345
+ out.keyOriginType = item.keyOriginType;
346
+ if (item.keyOriginResolution != null)
347
+ out.keyOriginResolution = item.keyOriginResolution;
348
+ var radii = item.keyOriginRRectRadii;
349
+ if (radii) {
350
+ out.keyOriginRRectRadii = {
351
+ unitValueQuadVersion: 1,
352
+ topRight: (0, descriptor_1.unitsValue)(radii.topRight, 'topRight'),
353
+ topLeft: (0, descriptor_1.unitsValue)(radii.topLeft, 'topLeft'),
354
+ bottomLeft: (0, descriptor_1.unitsValue)(radii.bottomLeft, 'bottomLeft'),
355
+ bottomRight: (0, descriptor_1.unitsValue)(radii.bottomRight, 'bottomRight'),
356
+ };
344
357
  }
345
- else {
346
- desc.keyDescriptorList.push({}); // we're adding keyOriginIndex at the end
347
- var out = desc.keyDescriptorList[desc.keyDescriptorList.length - 1];
348
- if (item.keyOriginType != null)
349
- out.keyOriginType = item.keyOriginType;
350
- if (item.keyOriginResolution != null)
351
- out.keyOriginResolution = item.keyOriginResolution;
352
- var radii = item.keyOriginRRectRadii;
353
- if (radii) {
354
- out.keyOriginRRectRadii = {
355
- unitValueQuadVersion: 1,
356
- topRight: (0, descriptor_1.unitsValue)(radii.topRight, 'topRight'),
357
- topLeft: (0, descriptor_1.unitsValue)(radii.topLeft, 'topLeft'),
358
- bottomLeft: (0, descriptor_1.unitsValue)(radii.bottomLeft, 'bottomLeft'),
359
- bottomRight: (0, descriptor_1.unitsValue)(radii.bottomRight, 'bottomRight'),
360
- };
361
- }
362
- var box = item.keyOriginShapeBoundingBox;
363
- if (box) {
364
- out.keyOriginShapeBBox = {
365
- unitValueQuadVersion: 1,
366
- 'Top ': (0, descriptor_1.unitsValue)(box.top, 'top'),
367
- Left: (0, descriptor_1.unitsValue)(box.left, 'left'),
368
- Btom: (0, descriptor_1.unitsValue)(box.bottom, 'bottom'),
369
- Rght: (0, descriptor_1.unitsValue)(box.right, 'right'),
370
- };
371
- }
372
- var corners = item.keyOriginBoxCorners;
373
- if (corners && corners.length === 4) {
374
- out.keyOriginBoxCorners = {
375
- rectangleCornerA: { Hrzn: corners[0].x, Vrtc: corners[0].y },
376
- rectangleCornerB: { Hrzn: corners[1].x, Vrtc: corners[1].y },
377
- rectangleCornerC: { Hrzn: corners[2].x, Vrtc: corners[2].y },
378
- rectangleCornerD: { Hrzn: corners[3].x, Vrtc: corners[3].y },
379
- };
380
- }
381
- var transform = item.transform;
382
- if (transform && transform.length === 6) {
383
- out.Trnf = {
384
- xx: transform[0],
385
- xy: transform[1],
386
- yx: transform[2],
387
- yy: transform[3],
388
- tx: transform[4],
389
- ty: transform[5],
390
- };
391
- }
392
- out.keyOriginIndex = i;
358
+ var box = item.keyOriginShapeBoundingBox;
359
+ if (box) {
360
+ out.keyOriginShapeBBox = {
361
+ unitValueQuadVersion: 1,
362
+ 'Top ': (0, descriptor_1.unitsValue)(box.top, 'top'),
363
+ Left: (0, descriptor_1.unitsValue)(box.left, 'left'),
364
+ Btom: (0, descriptor_1.unitsValue)(box.bottom, 'bottom'),
365
+ Rght: (0, descriptor_1.unitsValue)(box.right, 'right'),
366
+ };
367
+ }
368
+ var corners = item.keyOriginBoxCorners;
369
+ if (corners && corners.length === 4) {
370
+ out.keyOriginBoxCorners = {
371
+ rectangleCornerA: { Hrzn: corners[0].x, Vrtc: corners[0].y },
372
+ rectangleCornerB: { Hrzn: corners[1].x, Vrtc: corners[1].y },
373
+ rectangleCornerC: { Hrzn: corners[2].x, Vrtc: corners[2].y },
374
+ rectangleCornerD: { Hrzn: corners[3].x, Vrtc: corners[3].y },
375
+ };
376
+ }
377
+ var transform = item.transform;
378
+ if (transform && transform.length === 6) {
379
+ out.Trnf = {
380
+ xx: transform[0],
381
+ xy: transform[1],
382
+ yx: transform[2],
383
+ yy: transform[3],
384
+ tx: transform[4],
385
+ ty: transform[5],
386
+ };
393
387
  }
388
+ if (item.keyShapeInvalidated != null)
389
+ out.keyShapeInvalidated = item.keyShapeInvalidated;
390
+ out.keyOriginIndex = i;
394
391
  }
395
392
  (0, psdWriter_1.writeInt32)(writer, 1); // version
396
393
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
@@ -862,7 +859,13 @@ function isQuiltWarp(warp) {
862
859
  }
863
860
  function encodeWarp(warp) {
864
861
  var bounds = warp.bounds;
865
- var desc = __assign(__assign({ warpStyle: descriptor_1.warpStyle.encode(warp.style) }, (warp.values ? { warpValues: warp.values } : { warpValue: warp.value || 0 })), { warpPerspective: warp.perspective || 0, warpPerspectiveOther: warp.perspectiveOther || 0, warpRotate: descriptor_1.Ornt.encode(warp.rotate), bounds: {
862
+ var desc = __assign(__assign({ warpStyle: descriptor_1.warpStyle.encode(warp.style) }, (warp.values ? { warpValues: warp.values } : { warpValue: warp.value || 0 })), { warpPerspective: warp.perspective || 0, warpPerspectiveOther: warp.perspectiveOther || 0, warpRotate: descriptor_1.Ornt.encode(warp.rotate), bounds: /*1 ? { // testing
863
+ _classID: 'classFloatRect',
864
+ 'Top ': bounds && bounds.top && bounds.top.value || 0,
865
+ Left: bounds && bounds.left && bounds.left.value || 0,
866
+ Btom: bounds && bounds.bottom && bounds.bottom.value || 0,
867
+ Rght: bounds && bounds.right && bounds.right.value || 0,
868
+ } :*/ {
866
869
  'Top ': (0, descriptor_1.unitsValue)(bounds && bounds.top || { units: 'Pixels', value: 0 }, 'bounds.top'),
867
870
  Left: (0, descriptor_1.unitsValue)(bounds && bounds.left || { units: 'Pixels', value: 0 }, 'bounds.left'),
868
871
  Btom: (0, descriptor_1.unitsValue)(bounds && bounds.bottom || { units: 'Pixels', value: 0 }, 'bounds.bottom'),
@@ -1427,6 +1430,7 @@ function serializeFilterFXItem(f) {
1427
1430
  'Rds ': uvRadius(f.filter),
1428
1431
  }, filterID: 697 });
1429
1432
  case 'gaussian blur': return __assign(__assign({}, base), { Fltr: {
1433
+ // _name: '高斯模糊', // Testing
1430
1434
  _name: 'Gaussian Blur',
1431
1435
  _classID: 'GsnB',
1432
1436
  'Rds ': uvRadius(f.filter),