ag-psd 17.0.3 → 17.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/additionalInfo.js +37 -35
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +37 -35
- package/dist-es/additionalInfo.js +37 -35
- package/dist-es/additionalInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +40 -36
package/CHANGELOG.md
CHANGED
package/dist/additionalInfo.js
CHANGED
|
@@ -865,9 +865,10 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
865
865
|
for (var i = 0; i < 8; i++)
|
|
866
866
|
(0, psdWriter_1.writeFloat64)(writer, placed.transform[i]);
|
|
867
867
|
(0, psdWriter_1.writeInt32)(writer, 0); // warp version
|
|
868
|
-
var
|
|
868
|
+
var warp = getWarpFromPlacedLayer(placed);
|
|
869
|
+
var isQuilt = isQuiltWarp(warp);
|
|
869
870
|
var type = isQuilt ? 'quiltWarp' : 'warp';
|
|
870
|
-
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(
|
|
871
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(warp), type);
|
|
871
872
|
});
|
|
872
873
|
function uint8ToFloat32(array) {
|
|
873
874
|
return new Float32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
|
|
@@ -1691,6 +1692,39 @@ function serializeFilterFXItem(f) {
|
|
|
1691
1692
|
}
|
|
1692
1693
|
}
|
|
1693
1694
|
// let t: any;
|
|
1695
|
+
function getWarpFromPlacedLayer(placed) {
|
|
1696
|
+
if (placed.warp)
|
|
1697
|
+
return placed.warp;
|
|
1698
|
+
if (!placed.width || !placed.height)
|
|
1699
|
+
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1700
|
+
var w = placed.width;
|
|
1701
|
+
var h = placed.height;
|
|
1702
|
+
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1703
|
+
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1704
|
+
return {
|
|
1705
|
+
style: 'custom',
|
|
1706
|
+
value: 0,
|
|
1707
|
+
perspective: 0,
|
|
1708
|
+
perspectiveOther: 0,
|
|
1709
|
+
rotate: 'horizontal',
|
|
1710
|
+
bounds: {
|
|
1711
|
+
top: { value: 0, units: 'Pixels' },
|
|
1712
|
+
left: { value: 0, units: 'Pixels' },
|
|
1713
|
+
bottom: { value: h, units: 'Pixels' },
|
|
1714
|
+
right: { value: w, units: 'Pixels' },
|
|
1715
|
+
},
|
|
1716
|
+
uOrder: 4,
|
|
1717
|
+
vOrder: 4,
|
|
1718
|
+
customEnvelopeWarp: {
|
|
1719
|
+
meshPoints: [
|
|
1720
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1721
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1722
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1723
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1724
|
+
],
|
|
1725
|
+
},
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1694
1728
|
addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
1695
1729
|
if ((0, psdReader_1.readSignature)(reader) !== 'soLD')
|
|
1696
1730
|
throw new Error("Invalid SoLd type");
|
|
@@ -1742,44 +1776,12 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1742
1776
|
(0, psdWriter_1.writeSignature)(writer, 'soLD');
|
|
1743
1777
|
(0, psdWriter_1.writeInt32)(writer, 4); // version
|
|
1744
1778
|
var placed = target.placedLayer;
|
|
1745
|
-
var warp = placed.warp;
|
|
1746
|
-
if (!warp) {
|
|
1747
|
-
if (!placed.width || !placed.height)
|
|
1748
|
-
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1749
|
-
var w = placed.width;
|
|
1750
|
-
var h = placed.height;
|
|
1751
|
-
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1752
|
-
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1753
|
-
warp = {
|
|
1754
|
-
style: 'custom',
|
|
1755
|
-
value: 0,
|
|
1756
|
-
perspective: 0,
|
|
1757
|
-
perspectiveOther: 0,
|
|
1758
|
-
rotate: 'horizontal',
|
|
1759
|
-
bounds: {
|
|
1760
|
-
top: { value: 0, units: 'Pixels' },
|
|
1761
|
-
left: { value: 0, units: 'Pixels' },
|
|
1762
|
-
bottom: { value: h, units: 'Pixels' },
|
|
1763
|
-
right: { value: w, units: 'Pixels' },
|
|
1764
|
-
},
|
|
1765
|
-
uOrder: 4,
|
|
1766
|
-
vOrder: 4,
|
|
1767
|
-
customEnvelopeWarp: {
|
|
1768
|
-
meshPoints: [
|
|
1769
|
-
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1770
|
-
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1771
|
-
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1772
|
-
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1773
|
-
],
|
|
1774
|
-
},
|
|
1775
|
-
};
|
|
1776
|
-
}
|
|
1777
1779
|
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1778
1780
|
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1779
1781
|
}
|
|
1780
1782
|
var desc = __assign(__assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
|
|
1781
1783
|
// quiltWarp: {} as any,
|
|
1782
|
-
warp: encodeWarp(
|
|
1784
|
+
warp: encodeWarp(getWarpFromPlacedLayer(placed)), 'Sz ': {
|
|
1783
1785
|
_name: '',
|
|
1784
1786
|
_classID: 'Pnt ',
|
|
1785
1787
|
Wdth: placed.width || 0,
|