ag-psd 17.0.2 → 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 +6 -0
- package/dist/additionalInfo.js +47 -4
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +47 -4
- package/dist-es/additionalInfo.js +47 -4
- package/dist-es/additionalInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +52 -5
- package/src/psd.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v17.0.4
|
|
4
|
+
- Fixed saving smart layers without placedLayer.warp field present for newer versions of photoshop
|
|
5
|
+
|
|
6
|
+
## v17.0.3
|
|
7
|
+
- Added extra error checks and fixed writing PSD without placedLayer.warp field present
|
|
8
|
+
|
|
3
9
|
## v17.0.2
|
|
4
10
|
- Fixed issues with writing some layer effects
|
|
5
11
|
|
package/dist/additionalInfo.js
CHANGED
|
@@ -852,6 +852,9 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
852
852
|
var placed = target.placedLayer;
|
|
853
853
|
(0, psdWriter_1.writeSignature)(writer, 'plcL');
|
|
854
854
|
(0, psdWriter_1.writeInt32)(writer, 3); // version
|
|
855
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
856
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
857
|
+
}
|
|
855
858
|
(0, psdWriter_1.writePascalString)(writer, placed.id, 1);
|
|
856
859
|
(0, psdWriter_1.writeInt32)(writer, 1); // pageNumber
|
|
857
860
|
(0, psdWriter_1.writeInt32)(writer, 1); // totalPages
|
|
@@ -862,9 +865,10 @@ addHandler('PlLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
862
865
|
for (var i = 0; i < 8; i++)
|
|
863
866
|
(0, psdWriter_1.writeFloat64)(writer, placed.transform[i]);
|
|
864
867
|
(0, psdWriter_1.writeInt32)(writer, 0); // warp version
|
|
865
|
-
var
|
|
868
|
+
var warp = getWarpFromPlacedLayer(placed);
|
|
869
|
+
var isQuilt = isQuiltWarp(warp);
|
|
866
870
|
var type = isQuilt ? 'quiltWarp' : 'warp';
|
|
867
|
-
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(
|
|
871
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', type, encodeWarp(warp), type);
|
|
868
872
|
});
|
|
869
873
|
function uint8ToFloat32(array) {
|
|
870
874
|
return new Float32Array(array.buffer.slice(array.byteOffset), 0, array.byteLength / 4);
|
|
@@ -1688,6 +1692,39 @@ function serializeFilterFXItem(f) {
|
|
|
1688
1692
|
}
|
|
1689
1693
|
}
|
|
1690
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
|
+
}
|
|
1691
1728
|
addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
1692
1729
|
if ((0, psdReader_1.readSignature)(reader) !== 'soLD')
|
|
1693
1730
|
throw new Error("Invalid SoLd type");
|
|
@@ -1739,9 +1776,12 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
|
|
|
1739
1776
|
(0, psdWriter_1.writeSignature)(writer, 'soLD');
|
|
1740
1777
|
(0, psdWriter_1.writeInt32)(writer, 4); // version
|
|
1741
1778
|
var placed = target.placedLayer;
|
|
1779
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1780
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1781
|
+
}
|
|
1742
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,
|
|
1743
1783
|
// quiltWarp: {} as any,
|
|
1744
|
-
warp: encodeWarp(placed
|
|
1784
|
+
warp: encodeWarp(getWarpFromPlacedLayer(placed)), 'Sz ': {
|
|
1745
1785
|
_name: '',
|
|
1746
1786
|
_classID: 'Pnt ',
|
|
1747
1787
|
Wdth: placed.width || 0,
|
|
@@ -2009,7 +2049,10 @@ addHandler('lnk2', function (target) { return !!target.linkedFiles && target.lin
|
|
|
2009
2049
|
var sizeOffset = writer.offset;
|
|
2010
2050
|
(0, psdWriter_1.writeSignature)(writer, file.data ? 'liFD' : 'liFA');
|
|
2011
2051
|
(0, psdWriter_1.writeInt32)(writer, version);
|
|
2012
|
-
|
|
2052
|
+
if (!file.id || typeof file.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(file.id)) {
|
|
2053
|
+
throw new Error('Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
2054
|
+
}
|
|
2055
|
+
(0, psdWriter_1.writePascalString)(writer, file.id, 1);
|
|
2013
2056
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, file.name || '');
|
|
2014
2057
|
(0, psdWriter_1.writeSignature)(writer, file.type ? "".concat(file.type, " ").substring(0, 4) : ' ');
|
|
2015
2058
|
(0, psdWriter_1.writeSignature)(writer, file.creator ? "".concat(file.creator, " ").substring(0, 4) : '\0\0\0\0');
|