ag-psd 17.0.2 → 17.0.3
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 +43 -2
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +43 -2
- package/dist-es/additionalInfo.js +43 -2
- package/dist-es/additionalInfo.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +45 -2
- package/src/psd.ts +5 -5
package/package.json
CHANGED
package/src/additionalInfo.ts
CHANGED
|
@@ -1151,6 +1151,9 @@ addHandler(
|
|
|
1151
1151
|
const placed = target.placedLayer!;
|
|
1152
1152
|
writeSignature(writer, 'plcL');
|
|
1153
1153
|
writeInt32(writer, 3); // version
|
|
1154
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
1155
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
1156
|
+
}
|
|
1154
1157
|
writePascalString(writer, placed.id, 1);
|
|
1155
1158
|
writeInt32(writer, 1); // pageNumber
|
|
1156
1159
|
writeInt32(writer, 1); // totalPages
|
|
@@ -3168,6 +3171,43 @@ addHandler(
|
|
|
3168
3171
|
writeInt32(writer, 4); // version
|
|
3169
3172
|
|
|
3170
3173
|
const placed = target.placedLayer!;
|
|
3174
|
+
let warp = placed.warp;
|
|
3175
|
+
|
|
3176
|
+
if (!warp) {
|
|
3177
|
+
if (!placed.width || !placed.height) throw new Error('You must provide width and height of the linked image in placedLayer');
|
|
3178
|
+
const w = placed.width;
|
|
3179
|
+
const h = placed.height;
|
|
3180
|
+
const x0 = 0, x1 = w / 3, x2 = w * 2 / 3, x3 = w;
|
|
3181
|
+
const y0 = 0, y1 = h / 3, y2 = h * 2 / 3, y3 = h;
|
|
3182
|
+
warp = {
|
|
3183
|
+
style: 'custom',
|
|
3184
|
+
value: 0,
|
|
3185
|
+
perspective: 0,
|
|
3186
|
+
perspectiveOther: 0,
|
|
3187
|
+
rotate: 'horizontal',
|
|
3188
|
+
bounds: {
|
|
3189
|
+
top: { value: 0, units: 'Pixels' },
|
|
3190
|
+
left: { value: 0, units: 'Pixels' },
|
|
3191
|
+
bottom: { value: h, units: 'Pixels' },
|
|
3192
|
+
right: { value: w, units: 'Pixels' },
|
|
3193
|
+
},
|
|
3194
|
+
uOrder: 4,
|
|
3195
|
+
vOrder: 4,
|
|
3196
|
+
customEnvelopeWarp: {
|
|
3197
|
+
meshPoints: [
|
|
3198
|
+
{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x2, y: y0 }, { x: x3, y: y0 },
|
|
3199
|
+
{ x: x0, y: y1 }, { x: x1, y: y1 }, { x: x2, y: y1 }, { x: x3, y: y1 },
|
|
3200
|
+
{ x: x0, y: y2 }, { x: x1, y: y2 }, { x: x2, y: y2 }, { x: x3, y: y2 },
|
|
3201
|
+
{ x: x0, y: y3 }, { x: x1, y: y3 }, { x: x2, y: y3 }, { x: x3, y: y3 },
|
|
3202
|
+
],
|
|
3203
|
+
},
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
if (!placed.id || typeof placed.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(placed.id)) {
|
|
3208
|
+
throw new Error('Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3171
3211
|
const desc: SoLdDescriptor = {
|
|
3172
3212
|
Idnt: placed.id,
|
|
3173
3213
|
placed: placed.placed ?? placed.id,
|
|
@@ -3182,7 +3222,7 @@ addHandler(
|
|
|
3182
3222
|
Trnf: placed.transform,
|
|
3183
3223
|
nonAffineTransform: placed.nonAffineTransform ?? placed.transform,
|
|
3184
3224
|
// quiltWarp: {} as any,
|
|
3185
|
-
warp: encodeWarp(
|
|
3225
|
+
warp: encodeWarp(warp || {}),
|
|
3186
3226
|
'Sz ': {
|
|
3187
3227
|
_name: '',
|
|
3188
3228
|
_classID: 'Pnt ',
|
|
@@ -3480,7 +3520,10 @@ addHandler(
|
|
|
3480
3520
|
const sizeOffset = writer.offset;
|
|
3481
3521
|
writeSignature(writer, file.data ? 'liFD' : 'liFA');
|
|
3482
3522
|
writeInt32(writer, version);
|
|
3483
|
-
|
|
3523
|
+
if (!file.id || typeof file.id !== 'string' || !/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(file.id)) {
|
|
3524
|
+
throw new Error('Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)');
|
|
3525
|
+
}
|
|
3526
|
+
writePascalString(writer, file.id, 1);
|
|
3484
3527
|
writeUnicodeStringWithPadding(writer, file.name || '');
|
|
3485
3528
|
writeSignature(writer, file.type ? `${file.type} `.substring(0, 4) : ' ');
|
|
3486
3529
|
writeSignature(writer, file.creator ? `${file.creator} `.substring(0, 4) : '\0\0\0\0');
|
package/src/psd.ts
CHANGED
|
@@ -670,7 +670,7 @@ export interface SelectiveColorAdjustment {
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
export interface LinkedFile {
|
|
673
|
-
id: string;
|
|
673
|
+
id: string; // must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
|
|
674
674
|
name: string;
|
|
675
675
|
type?: string;
|
|
676
676
|
creator?: string;
|
|
@@ -1150,7 +1150,7 @@ export interface PlacedLayerFilter {
|
|
|
1150
1150
|
export type PlacedLayerType = 'unknown' | 'vector' | 'raster' | 'image stack';
|
|
1151
1151
|
|
|
1152
1152
|
export interface PlacedLayer {
|
|
1153
|
-
id: string; // id of linked image file (psd.linkedFiles)
|
|
1153
|
+
id: string; // id of linked image file (psd.linkedFiles), must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
|
|
1154
1154
|
placed?: string; // unique id
|
|
1155
1155
|
type: PlacedLayerType;
|
|
1156
1156
|
pageNumber?: number;
|
|
@@ -1160,11 +1160,11 @@ export interface PlacedLayer {
|
|
|
1160
1160
|
frameCount?: number;
|
|
1161
1161
|
transform: number[]; // x, y of 4 corners of the transform
|
|
1162
1162
|
nonAffineTransform?: number[]; // x, y of 4 corners of the transform
|
|
1163
|
-
width?: number;
|
|
1164
|
-
height?: number;
|
|
1163
|
+
width?: number; // width of the linked image
|
|
1164
|
+
height?: number; // height of the linked image
|
|
1165
1165
|
resolution?: UnitsValue;
|
|
1166
1166
|
// antialias ?
|
|
1167
|
-
warp?: Warp;
|
|
1167
|
+
warp?: Warp; // warp coordinates are relative to the linked image size
|
|
1168
1168
|
crop?: number;
|
|
1169
1169
|
comp?: number;
|
|
1170
1170
|
compInfo?: { compID: number; originalCompID: number; };
|