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/dist/bundle.js
CHANGED
|
@@ -1137,9 +1137,10 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1137
1137
|
for (var i = 0; i < 8; i++)
|
|
1138
1138
|
(0, psdWriter_1.writeFloat64)(writer, placed.transform[i]);
|
|
1139
1139
|
(0, psdWriter_1.writeInt32)(writer, 0); // warp version
|
|
1140
|
-
var
|
|
1140
|
+
var warp = getWarpFromPlacedLayer(placed);
|
|
1141
|
+
var isQuilt = isQuiltWarp(warp);
|
|
1141
1142
|
var type = isQuilt ? 'quiltWarp' : 'warp';
|
|
1142
|
-
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(
|
|
1143
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(warp), type);
|
|
1143
1144
|
});
|
|
1144
1145
|
function uint8ToFloat32(array) {
|
|
1145
1146
|
return new Float32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
|
|
@@ -1963,6 +1964,39 @@ function serializeFilterFXItem(f) {
|
|
|
1963
1964
|
}
|
|
1964
1965
|
}
|
|
1965
1966
|
// let t: any;
|
|
1967
|
+
function getWarpFromPlacedLayer(placed) {
|
|
1968
|
+
if (placed.warp)
|
|
1969
|
+
return placed.warp;
|
|
1970
|
+
if (!placed.width || !placed.height)
|
|
1971
|
+
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1972
|
+
var w = placed.width;
|
|
1973
|
+
var h = placed.height;
|
|
1974
|
+
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1975
|
+
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1976
|
+
return {
|
|
1977
|
+
style: 'custom',
|
|
1978
|
+
value: 0,
|
|
1979
|
+
perspective: 0,
|
|
1980
|
+
perspectiveOther: 0,
|
|
1981
|
+
rotate: 'horizontal',
|
|
1982
|
+
bounds: {
|
|
1983
|
+
top: { value: 0, units: 'Pixels' },
|
|
1984
|
+
left: { value: 0, units: 'Pixels' },
|
|
1985
|
+
bottom: { value: h, units: 'Pixels' },
|
|
1986
|
+
right: { value: w, units: 'Pixels' },
|
|
1987
|
+
},
|
|
1988
|
+
uOrder: 4,
|
|
1989
|
+
vOrder: 4,
|
|
1990
|
+
customEnvelopeWarp: {
|
|
1991
|
+
meshPoints: [
|
|
1992
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1993
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1994
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1995
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1996
|
+
],
|
|
1997
|
+
},
|
|
1998
|
+
};
|
|
1999
|
+
}
|
|
1966
2000
|
addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
1967
2001
|
if ((0, psdReader_1.readSignature)(reader) !== 'soLD')
|
|
1968
2002
|
throw new Error("Invalid SoLd type");
|
|
@@ -2014,44 +2048,12 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
2014
2048
|
(0, psdWriter_1.writeSignature)(writer, 'soLD');
|
|
2015
2049
|
(0, psdWriter_1.writeInt32)(writer, 4); // version
|
|
2016
2050
|
var placed = target.placedLayer;
|
|
2017
|
-
var warp = placed.warp;
|
|
2018
|
-
if (!warp) {
|
|
2019
|
-
if (!placed.width || !placed.height)
|
|
2020
|
-
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
2021
|
-
var w = placed.width;
|
|
2022
|
-
var h = placed.height;
|
|
2023
|
-
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
2024
|
-
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
2025
|
-
warp = {
|
|
2026
|
-
style: 'custom',
|
|
2027
|
-
value: 0,
|
|
2028
|
-
perspective: 0,
|
|
2029
|
-
perspectiveOther: 0,
|
|
2030
|
-
rotate: 'horizontal',
|
|
2031
|
-
bounds: {
|
|
2032
|
-
top: { value: 0, units: 'Pixels' },
|
|
2033
|
-
left: { value: 0, units: 'Pixels' },
|
|
2034
|
-
bottom: { value: h, units: 'Pixels' },
|
|
2035
|
-
right: { value: w, units: 'Pixels' },
|
|
2036
|
-
},
|
|
2037
|
-
uOrder: 4,
|
|
2038
|
-
vOrder: 4,
|
|
2039
|
-
customEnvelopeWarp: {
|
|
2040
|
-
meshPoints: [
|
|
2041
|
-
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
2042
|
-
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
2043
|
-
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
2044
|
-
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
2045
|
-
],
|
|
2046
|
-
},
|
|
2047
|
-
};
|
|
2048
|
-
}
|
|
2049
2051
|
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
2050
2052
|
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
2051
2053
|
}
|
|
2052
2054
|
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,
|
|
2053
2055
|
// quiltWarp: {} as any,
|
|
2054
|
-
warp: encodeWarp(
|
|
2056
|
+
warp: encodeWarp(getWarpFromPlacedLayer(placed)), 'Sz ': {
|
|
2055
2057
|
_name: '',
|
|
2056
2058
|
_classID: 'Pnt ',
|
|
2057
2059
|
Wdth: placed.width || 0,
|
|
@@ -860,9 +860,10 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
860
860
|
for (var i = 0; i < 8; i++)
|
|
861
861
|
writeFloat64(writer, placed.transform[i]);
|
|
862
862
|
writeInt32(writer, 0); // warp version
|
|
863
|
-
var
|
|
863
|
+
var warp = getWarpFromPlacedLayer(placed);
|
|
864
|
+
var isQuilt = isQuiltWarp(warp);
|
|
864
865
|
var type = isQuilt ? 'quiltWarp' : 'warp';
|
|
865
|
-
writeVersionAndDescriptor(writer, '', type, encodeWarp(
|
|
866
|
+
writeVersionAndDescriptor(writer, '', type, encodeWarp(warp), type);
|
|
866
867
|
});
|
|
867
868
|
function uint8ToFloat32(array) {
|
|
868
869
|
return new Float32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
|
|
@@ -1686,6 +1687,39 @@ function serializeFilterFXItem(f) {
|
|
|
1686
1687
|
}
|
|
1687
1688
|
}
|
|
1688
1689
|
// let t: any;
|
|
1690
|
+
function getWarpFromPlacedLayer(placed) {
|
|
1691
|
+
if (placed.warp)
|
|
1692
|
+
return placed.warp;
|
|
1693
|
+
if (!placed.width || !placed.height)
|
|
1694
|
+
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1695
|
+
var w = placed.width;
|
|
1696
|
+
var h = placed.height;
|
|
1697
|
+
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1698
|
+
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1699
|
+
return {
|
|
1700
|
+
style: 'custom',
|
|
1701
|
+
value: 0,
|
|
1702
|
+
perspective: 0,
|
|
1703
|
+
perspectiveOther: 0,
|
|
1704
|
+
rotate: 'horizontal',
|
|
1705
|
+
bounds: {
|
|
1706
|
+
top: { value: 0, units: 'Pixels' },
|
|
1707
|
+
left: { value: 0, units: 'Pixels' },
|
|
1708
|
+
bottom: { value: h, units: 'Pixels' },
|
|
1709
|
+
right: { value: w, units: 'Pixels' },
|
|
1710
|
+
},
|
|
1711
|
+
uOrder: 4,
|
|
1712
|
+
vOrder: 4,
|
|
1713
|
+
customEnvelopeWarp: {
|
|
1714
|
+
meshPoints: [
|
|
1715
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1716
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1717
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1718
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1719
|
+
],
|
|
1720
|
+
},
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1689
1723
|
addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
1690
1724
|
if (readSignature(reader) !== 'soLD')
|
|
1691
1725
|
throw new Error("Invalid SoLd type");
|
|
@@ -1737,44 +1771,12 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1737
1771
|
writeSignature(writer, 'soLD');
|
|
1738
1772
|
writeInt32(writer, 4); // version
|
|
1739
1773
|
var placed = target.placedLayer;
|
|
1740
|
-
var warp = placed.warp;
|
|
1741
|
-
if (!warp) {
|
|
1742
|
-
if (!placed.width || !placed.height)
|
|
1743
|
-
throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
1744
|
-
var w = placed.width;
|
|
1745
|
-
var h = placed.height;
|
|
1746
|
-
var x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
1747
|
-
var y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
1748
|
-
warp = {
|
|
1749
|
-
style: 'custom',
|
|
1750
|
-
value: 0,
|
|
1751
|
-
perspective: 0,
|
|
1752
|
-
perspectiveOther: 0,
|
|
1753
|
-
rotate: 'horizontal',
|
|
1754
|
-
bounds: {
|
|
1755
|
-
top: { value: 0, units: 'Pixels' },
|
|
1756
|
-
left: { value: 0, units: 'Pixels' },
|
|
1757
|
-
bottom: { value: h, units: 'Pixels' },
|
|
1758
|
-
right: { value: w, units: 'Pixels' },
|
|
1759
|
-
},
|
|
1760
|
-
uOrder: 4,
|
|
1761
|
-
vOrder: 4,
|
|
1762
|
-
customEnvelopeWarp: {
|
|
1763
|
-
meshPoints: [
|
|
1764
|
-
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
1765
|
-
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
1766
|
-
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
1767
|
-
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
1768
|
-
],
|
|
1769
|
-
},
|
|
1770
|
-
};
|
|
1771
|
-
}
|
|
1772
1774
|
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1773
1775
|
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1774
1776
|
}
|
|
1775
1777
|
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,
|
|
1776
1778
|
// quiltWarp: {} as any,
|
|
1777
|
-
warp: encodeWarp(
|
|
1779
|
+
warp: encodeWarp(getWarpFromPlacedLayer(placed)), 'Sz ': {
|
|
1778
1780
|
_name: '',
|
|
1779
1781
|
_classID: 'Pnt ',
|
|
1780
1782
|
Wdth: placed.width || 0,
|