ag-psd 28.4.1 → 28.5.1
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/.v8-cache/v22.13.1-x64-00250a7c/7ea06cea +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/b3c2fab7 +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/cd260961 +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/e03e2acd +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/e6745c2b +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/e6b99945 +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/eeeebdfe +0 -0
- package/.v8-cache/v22.13.1-x64-00250a7c/fb01f274 +0 -0
- package/CHANGELOG.md +7 -0
- package/dist/abr.d.ts +56 -4
- package/dist/abr.js +85 -16
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.js +91 -9
- package/dist/additionalInfo.js.map +1 -1
- package/dist/ase.d.ts +32 -0
- package/dist/ase.js +83 -0
- package/dist/ase.js.map +1 -0
- package/dist/bundle.js +2324 -50
- package/dist/descriptor.d.ts +35 -0
- package/dist/descriptor.js.map +1 -1
- package/dist/psd.d.ts +23 -0
- package/dist/psd.js.map +1 -1
- package/dist-es/abr.d.ts +56 -4
- package/dist-es/abr.js +85 -16
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.js +91 -9
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/ase.d.ts +32 -0
- package/dist-es/ase.js +79 -0
- package/dist-es/ase.js.map +1 -0
- package/dist-es/descriptor.d.ts +35 -0
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/psd.d.ts +23 -0
- package/dist-es/psd.js.map +1 -1
- package/package.json +1 -1
- package/src/abr.ts +216 -26
- package/src/additionalInfo.ts +98 -9
- package/src/ase.ts +116 -0
- package/src/descriptor.ts +33 -0
- package/src/psd.ts +20 -0
package/src/abr.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { BlnM, DescriptorUnitsValue, parseAngle, parsePercent, parseUnitsToNumber, readVersionAndDescriptor } from './descriptor';
|
|
2
2
|
import { BlendMode, PatternInfo } from './psd';
|
|
3
|
-
import {
|
|
4
|
-
checkSignature, createReader, readBytes, readDataRLE, readInt16, readInt32, readPascalString, readPattern,
|
|
5
|
-
readSignature, readUint16, readUint32, readUint8, skipBytes
|
|
6
|
-
} from './psdReader';
|
|
3
|
+
import { checkSignature, createReader, readBytes, readDataRLE, readInt16, readInt32, readPascalString, readPattern, readSignature, readUint16, readUint32, readUint8, skipBytes } from './psdReader';
|
|
7
4
|
|
|
8
5
|
export interface Abr {
|
|
9
6
|
brushes: Brush[];
|
|
@@ -26,17 +23,78 @@ export interface BrushDynamics {
|
|
|
26
23
|
|
|
27
24
|
const dynamicsControl = ['off', 'fade', 'pen pressure', 'pen tilt', 'stylus wheel', 'initial direction', 'direction', 'initial rotation', 'rotation'];
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
type DynamicBrushShapeShape = 'round point' | 'round blunt' | 'round curve' | 'round angle' | 'round fan' | 'flat point' | 'flat blunt' | 'flat curve' | 'flat angle' | 'flat fan';
|
|
27
|
+
|
|
28
|
+
const dynamicBrushShapeShapes: DynamicBrushShapeShape[] = ['round point', 'round blunt', 'round curve', 'round angle', 'round fan', 'flat point', 'flat blunt', 'flat curve', 'flat angle', 'flat fan'];
|
|
29
|
+
|
|
30
|
+
type TipsBrushShapeShape = 'erodible point' | 'erodible flat' | 'erodible round' | 'erodible square' | 'erodible triangle' | 'custom';
|
|
31
|
+
|
|
32
|
+
const tipsBrushShapeShapes: TipsBrushShapeShape[] = ['erodible point', 'erodible flat', 'erodible round', 'erodible square', 'erodible triangle', 'custom'];
|
|
33
|
+
|
|
34
|
+
export type BrushShape = ComputedBrushShape | SampledBrushShape | TipsBrushShape | DynamicBrushShape;
|
|
35
|
+
|
|
36
|
+
interface ComputedBrushShape {
|
|
37
|
+
type: 'computed';
|
|
38
|
+
size: number;
|
|
39
|
+
angle: number;
|
|
40
|
+
roundness: number;
|
|
41
|
+
hardness: number;
|
|
42
|
+
spacingOn: boolean;
|
|
43
|
+
spacing: number;
|
|
44
|
+
flipX: boolean;
|
|
45
|
+
flipY: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface SampledBrushShape {
|
|
49
|
+
type: 'sampled';
|
|
50
|
+
name: string;
|
|
31
51
|
size: number;
|
|
32
52
|
angle: number;
|
|
33
53
|
roundness: number;
|
|
34
|
-
hardness?: number;
|
|
35
54
|
spacingOn: boolean;
|
|
36
55
|
spacing: number;
|
|
37
56
|
flipX: boolean;
|
|
38
57
|
flipY: boolean;
|
|
39
|
-
sampledData
|
|
58
|
+
sampledData: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TipsBrushShape {
|
|
62
|
+
type: 'tips';
|
|
63
|
+
angle: number;
|
|
64
|
+
size: number;
|
|
65
|
+
shape: DynamicBrushShapeShape;
|
|
66
|
+
physics: boolean;
|
|
67
|
+
spacing: number,
|
|
68
|
+
spacingOn: boolean;
|
|
69
|
+
flipX: boolean;
|
|
70
|
+
flipY: boolean;
|
|
71
|
+
tipsType: TipsBrushShapeShape;
|
|
72
|
+
tipsLengthRatio: number;
|
|
73
|
+
tipsHardness: number;
|
|
74
|
+
tipsGridSize?: number;
|
|
75
|
+
tipsErodibleTipHeightMap?: number[];
|
|
76
|
+
tipsAirbrushCutoffAngle: number;
|
|
77
|
+
tipsAirbrushGranularity: number;
|
|
78
|
+
tipsAirbrushStreakiness: number;
|
|
79
|
+
tipsAirbrushSplatSize: number;
|
|
80
|
+
tipsAirbrushSplatCount: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface DynamicBrushShape {
|
|
84
|
+
type: 'dynamic';
|
|
85
|
+
size: number;
|
|
86
|
+
angle: number;
|
|
87
|
+
shape: DynamicBrushShapeShape;
|
|
88
|
+
density: number;
|
|
89
|
+
length: number;
|
|
90
|
+
clumping: number; // bristles
|
|
91
|
+
thickness: number;
|
|
92
|
+
stiffness: number;
|
|
93
|
+
physics: boolean;
|
|
94
|
+
spacing: number;
|
|
95
|
+
spacingOn: boolean;
|
|
96
|
+
flipX: boolean;
|
|
97
|
+
flipY: boolean;
|
|
40
98
|
}
|
|
41
99
|
|
|
42
100
|
export interface Brush {
|
|
@@ -164,17 +222,74 @@ interface DynamicsDescriptor {
|
|
|
164
222
|
'Mnm ': DescriptorUnitsValue;
|
|
165
223
|
}
|
|
166
224
|
|
|
167
|
-
|
|
225
|
+
type BrushShapeDescriptor = ComputedBrushDescriptor | SampledBrushDescriptor | TipsBrushDescriptor | DynamicBrushDescriptor;
|
|
226
|
+
|
|
227
|
+
interface ComputedBrushDescriptor {
|
|
228
|
+
_name: '';
|
|
229
|
+
_classID: 'computedBrush',
|
|
230
|
+
Dmtr: DescriptorUnitsValue,
|
|
231
|
+
Hrdn: DescriptorUnitsValue,
|
|
232
|
+
Angl: DescriptorUnitsValue,
|
|
233
|
+
Rndn: DescriptorUnitsValue,
|
|
234
|
+
Spcn: DescriptorUnitsValue,
|
|
235
|
+
Intr: boolean,
|
|
236
|
+
flipX: boolean,
|
|
237
|
+
flipY: boolean,
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
interface SampledBrushDescriptor {
|
|
241
|
+
_name: '';
|
|
242
|
+
_classID: 'sampledBrush';
|
|
168
243
|
Dmtr: DescriptorUnitsValue;
|
|
169
244
|
Angl: DescriptorUnitsValue;
|
|
170
245
|
Rndn: DescriptorUnitsValue;
|
|
171
|
-
'Nm '
|
|
246
|
+
'Nm ': string;
|
|
247
|
+
Spcn: DescriptorUnitsValue;
|
|
248
|
+
Intr: boolean;
|
|
249
|
+
flipX: boolean;
|
|
250
|
+
flipY: boolean;
|
|
251
|
+
sampledData: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
interface TipsBrushDescriptor {
|
|
255
|
+
_name: '';
|
|
256
|
+
_classID: 'dTips';
|
|
257
|
+
Angl: DescriptorUnitsValue;
|
|
258
|
+
Dmtr: DescriptorUnitsValue;
|
|
259
|
+
dtipsType: number;
|
|
260
|
+
'Shp ': number;
|
|
261
|
+
dtipsLengthRatio: DescriptorUnitsValue;
|
|
262
|
+
dtipsHardness: DescriptorUnitsValue;
|
|
263
|
+
dtipsGridSize: number;
|
|
264
|
+
dtipsErodibleTipHeightMap?: Uint8Array;
|
|
265
|
+
physics: boolean;
|
|
266
|
+
dtipsAirbrushCutoffAngle: number;
|
|
267
|
+
dtipsAirbrushGranularity: DescriptorUnitsValue;
|
|
268
|
+
dtipsAirbrushStreakiness: DescriptorUnitsValue;
|
|
269
|
+
dtipsAirbrushSplatSize: DescriptorUnitsValue;
|
|
270
|
+
dtipsAirbrushSplatCount: number;
|
|
271
|
+
Spcn: DescriptorUnitsValue,
|
|
272
|
+
Intr: boolean;
|
|
273
|
+
flipX: boolean;
|
|
274
|
+
flipY: boolean;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface DynamicBrushDescriptor {
|
|
278
|
+
_name: '';
|
|
279
|
+
_classID: 'dBrush';
|
|
280
|
+
'Shp ': number;
|
|
281
|
+
Angl: DescriptorUnitsValue;
|
|
282
|
+
Dmtr: DescriptorUnitsValue;
|
|
283
|
+
Dnst: DescriptorUnitsValue;
|
|
284
|
+
Lngt: DescriptorUnitsValue;
|
|
285
|
+
clumping: DescriptorUnitsValue;
|
|
286
|
+
thickness: DescriptorUnitsValue;
|
|
287
|
+
stiffness: DescriptorUnitsValue;
|
|
288
|
+
physics: boolean;
|
|
172
289
|
Spcn: DescriptorUnitsValue;
|
|
173
290
|
Intr: boolean;
|
|
174
|
-
Hrdn?: DescriptorUnitsValue;
|
|
175
291
|
flipX: boolean;
|
|
176
292
|
flipY: boolean;
|
|
177
|
-
sampledData?: string;
|
|
178
293
|
}
|
|
179
294
|
|
|
180
295
|
interface DescDescriptor {
|
|
@@ -305,21 +420,96 @@ function parseDynamics(desc: DynamicsDescriptor): BrushDynamics {
|
|
|
305
420
|
}
|
|
306
421
|
|
|
307
422
|
function parseBrushShape(desc: BrushShapeDescriptor): BrushShape {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
423
|
+
switch (desc._classID) {
|
|
424
|
+
case 'computedBrush': {
|
|
425
|
+
return {
|
|
426
|
+
type: 'computed',
|
|
427
|
+
size: parseUnitsToNumber(desc.Dmtr, 'Pixels'),
|
|
428
|
+
angle: parseAngle(desc.Angl),
|
|
429
|
+
roundness: parsePercent(desc.Rndn),
|
|
430
|
+
spacingOn: desc.Intr,
|
|
431
|
+
spacing: parsePercent(desc.Spcn),
|
|
432
|
+
flipX: desc.flipX,
|
|
433
|
+
flipY: desc.flipY,
|
|
434
|
+
hardness: parsePercent(desc.Hrdn),
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
case 'sampledBrush': {
|
|
438
|
+
return {
|
|
439
|
+
type: 'sampled',
|
|
440
|
+
size: parseUnitsToNumber(desc.Dmtr, 'Pixels'),
|
|
441
|
+
angle: parseAngle(desc.Angl),
|
|
442
|
+
roundness: parsePercent(desc.Rndn),
|
|
443
|
+
spacingOn: desc.Intr,
|
|
444
|
+
spacing: parsePercent(desc.Spcn),
|
|
445
|
+
flipX: desc.flipX,
|
|
446
|
+
flipY: desc.flipY,
|
|
447
|
+
name: desc['Nm '],
|
|
448
|
+
sampledData: desc.sampledData,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
case 'dBrush':
|
|
452
|
+
return {
|
|
453
|
+
type: 'dynamic',
|
|
454
|
+
shape: dynamicBrushShapeShapes[desc['Shp ']],
|
|
455
|
+
angle: parseAngle(desc.Angl),
|
|
456
|
+
size: parseUnitsToNumber(desc.Dmtr, 'Pixels'),
|
|
457
|
+
density: parsePercent(desc.Dnst),
|
|
458
|
+
length: parsePercent(desc.Lngt),
|
|
459
|
+
clumping: parsePercent(desc.clumping),
|
|
460
|
+
thickness: parsePercent(desc.thickness),
|
|
461
|
+
stiffness: parsePercent(desc.stiffness),
|
|
462
|
+
physics: desc.physics,
|
|
463
|
+
spacing: parsePercent(desc.Spcn),
|
|
464
|
+
spacingOn: desc.Intr,
|
|
465
|
+
flipX: desc.flipX,
|
|
466
|
+
flipY: desc.flipY,
|
|
467
|
+
};
|
|
468
|
+
case 'dTips': {
|
|
469
|
+
return {
|
|
470
|
+
type: 'tips',
|
|
471
|
+
angle: parseAngle(desc.Angl),
|
|
472
|
+
size: parseUnitsToNumber(desc.Dmtr, 'Pixels'),
|
|
473
|
+
shape: dynamicBrushShapeShapes[desc['Shp ']],
|
|
474
|
+
physics: desc.physics,
|
|
475
|
+
spacing: parsePercent(desc.Spcn),
|
|
476
|
+
spacingOn: desc.Intr,
|
|
477
|
+
flipX: desc.flipX,
|
|
478
|
+
flipY: desc.flipY,
|
|
479
|
+
// tips:
|
|
480
|
+
tipsType: tipsBrushShapeShapes[desc.dtipsType],
|
|
481
|
+
tipsLengthRatio: parsePercent(desc.dtipsLengthRatio),
|
|
482
|
+
tipsHardness: parsePercent(desc.dtipsHardness),
|
|
483
|
+
...(desc.dtipsGridSize && desc.dtipsErodibleTipHeightMap ? {
|
|
484
|
+
tipsGridSize: desc.dtipsGridSize,
|
|
485
|
+
tipsErodibleTipHeightMap: parseHeightmap(desc.dtipsErodibleTipHeightMap),
|
|
486
|
+
} : {}),
|
|
487
|
+
// airbrush
|
|
488
|
+
tipsAirbrushCutoffAngle: desc.dtipsAirbrushCutoffAngle,
|
|
489
|
+
tipsAirbrushGranularity: parsePercent(desc.dtipsAirbrushGranularity),
|
|
490
|
+
tipsAirbrushStreakiness: parsePercent(desc.dtipsAirbrushStreakiness),
|
|
491
|
+
tipsAirbrushSplatSize: parsePercent(desc.dtipsAirbrushSplatSize),
|
|
492
|
+
tipsAirbrushSplatCount: desc.dtipsAirbrushSplatCount,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
default:
|
|
496
|
+
console.log(require('util').inspect(desc, false, 99, true));
|
|
497
|
+
throw new Error(`Unknown brush classId: ${(desc as any)._classID}`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
321
500
|
|
|
322
|
-
|
|
501
|
+
function parseHeightmap(array: Uint8Array) {
|
|
502
|
+
const result: number[] = [];
|
|
503
|
+
for (let i = 0; i < array.byteLength; i++) {
|
|
504
|
+
result.push(array[i]);
|
|
505
|
+
}
|
|
506
|
+
return result;
|
|
507
|
+
// const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
508
|
+
// const result: number[] = [];
|
|
509
|
+
// for (let i = 0, len = (array.byteLength / 4) | 0; i < len; i++) {
|
|
510
|
+
// result.push(view.getInt32(i * 4)); ????
|
|
511
|
+
// }
|
|
512
|
+
// return result;
|
|
323
513
|
}
|
|
324
514
|
|
|
325
515
|
export function readAbr(buffer: ArrayBufferView, options: { logMissingFeatures?: boolean; } = {}): Abr {
|
package/src/additionalInfo.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { clamp, createEnum, layerColors, MOCK_HANDLERS } from './helpers';
|
|
|
4
4
|
import { LayerAdditionalInfo, BezierPath, Psd, BrightnessAdjustment, ExposureAdjustment, VibranceAdjustment, ColorBalanceAdjustment, BlackAndWhiteAdjustment, PhotoFilterAdjustment, ChannelMixerChannel, ChannelMixerAdjustment, PosterizeAdjustment, ThresholdAdjustment, GradientMapAdjustment, CMYK, SelectiveColorAdjustment, ColorLookupAdjustment, LevelsAdjustmentChannel, LevelsAdjustment, CurvesAdjustment, CurvesAdjustmentChannel, HueSaturationAdjustment, HueSaturationAdjustmentChannel, PresetInfo, Color, ColorBalanceValues, WriteOptions, LinkedFile, PlacedLayerType, Warp, KeyDescriptorItem, BooleanOperation, LayerEffectsInfo, Annotation, LayerVectorMask, AnimationFrame, Timeline, PlacedLayerFilter, UnitsValue, Filter, PlacedLayer, ReadOptions, Layer } from './psd';
|
|
5
5
|
import { PsdReader, readSignature, readUnicodeString, skipBytes, readUint32, readUint8, readFloat64, readUint16, readBytes, readInt16, checkSignature, readFloat32, readFixedPointPath32, readSection, readColor, readInt32, readPascalString, readUnicodeStringWithLength, readAsciiString, readPattern, readLayerInfo } from './psdReader';
|
|
6
6
|
import { PsdWriter, writeZeros, writeSignature, writeBytes, writeUint32, writeUint16, writeFloat64, writeUint8, writeInt16, writeFloat32, writeFixedPointPath32, writeUnicodeString, writeSection, writeUnicodeStringWithPadding, writeColor, writePascalString, writeInt32 } from './psdWriter';
|
|
7
|
-
import { Annt, BlnM, DescriptorColor, DescriptorUnitsValue, parsePercent, parseUnits, parseUnitsOrNumber, QuiltWarpDescriptor, strokeStyleLineAlignment, strokeStyleLineCapType, strokeStyleLineJoinType, TextDescriptor, textGridding, unitsPercent, unitsValue, WarpDescriptor, warpStyle, writeVersionAndDescriptor, readVersionAndDescriptor, StrokeDescriptor, Ornt, horzVrtcToXY, LmfxDescriptor, Lfx2Descriptor, FrameListDescriptor, TimelineDescriptor, FrameDescriptor, xyToHorzVrtc, serializeEffects, parseEffects, parseColor, serializeColor, serializeVectorContent, parseVectorContent, parseTrackList, serializeTrackList, FractionDescriptor, BlrM, BlrQ, SmBQ, SmBM, DspM, UndA, Cnvr, RplS, SphM, Wvtp, ZZTy, Dstr, Chnl, MztT, Lns, blurType, DfsM, ExtT, ExtR, FlCl, CntE, WndM, Drct, IntE, IntC, FlMd, unitsPercentF, frac, ClrS, descBoundsToBounds, boundsToDescBounds, presetKindType, gradientInterpolationMethodType } from './descriptor';
|
|
7
|
+
import { Annt, BlnM, DescriptorColor, DescriptorUnitsValue, parsePercent, parseUnits, parseUnitsOrNumber, QuiltWarpDescriptor, strokeStyleLineAlignment, strokeStyleLineCapType, strokeStyleLineJoinType, TextDescriptor, textGridding, unitsPercent, unitsValue, WarpDescriptor, warpStyle, writeVersionAndDescriptor, readVersionAndDescriptor, StrokeDescriptor, Ornt, horzVrtcToXY, LmfxDescriptor, Lfx2Descriptor, FrameListDescriptor, TimelineDescriptor, FrameDescriptor, xyToHorzVrtc, serializeEffects, parseEffects, parseColor, serializeColor, serializeVectorContent, parseVectorContent, parseTrackList, serializeTrackList, FractionDescriptor, BlrM, BlrQ, SmBQ, SmBM, DspM, UndA, Cnvr, RplS, SphM, Wvtp, ZZTy, Dstr, Chnl, MztT, Lns, blurType, DfsM, ExtT, ExtR, FlCl, CntE, WndM, Drct, IntE, IntC, FlMd, unitsPercentF, frac, ClrS, descBoundsToBounds, boundsToDescBounds, presetKindType, gradientInterpolationMethodType, PxScDescriptor } from './descriptor';
|
|
8
8
|
import { serializeEngineData, parseEngineData } from './engineData';
|
|
9
9
|
import { encodeEngineData, decodeEngineData } from './text';
|
|
10
10
|
import { decodeEngineData2 } from './engineData2';
|
|
@@ -442,7 +442,7 @@ addHandler(
|
|
|
442
442
|
}
|
|
443
443
|
const trnf = i.Trnf;
|
|
444
444
|
if (trnf) {
|
|
445
|
-
item.transform = [trnf.xx, trnf.xy, trnf.
|
|
445
|
+
item.transform = [trnf.xx, trnf.xy, trnf.yx, trnf.yy, trnf.tx, trnf.ty];
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
target.vectorOrigination.keyDescriptorList.push(item);
|
|
@@ -978,6 +978,76 @@ addHandler(
|
|
|
978
978
|
},
|
|
979
979
|
);
|
|
980
980
|
|
|
981
|
+
addHandler(
|
|
982
|
+
'PxSc',
|
|
983
|
+
() => false,
|
|
984
|
+
(reader, target) => {
|
|
985
|
+
const desc = readVersionAndDescriptor(reader, true) as PxScDescriptor;
|
|
986
|
+
// console.log('PxSc', require('util').inspect(desc, false, 99, true));
|
|
987
|
+
|
|
988
|
+
if (desc.pixelSourceType === 1986285651) {
|
|
989
|
+
target.pixelSource = {
|
|
990
|
+
type: 'vdPS',
|
|
991
|
+
origin: { x: desc.origin.Hrzn, y: desc.origin.Vrtc },
|
|
992
|
+
interpretation: {
|
|
993
|
+
interpretAlpha: desc.interpretation.interpretAlpha.split('.')[1] as any,
|
|
994
|
+
profile: desc.interpretation.profile,
|
|
995
|
+
},
|
|
996
|
+
frameReader: {
|
|
997
|
+
type: 'QTFR',
|
|
998
|
+
link: {
|
|
999
|
+
name: desc.frameReader['Lnk ']['Nm '],
|
|
1000
|
+
fullPath: desc.frameReader['Lnk '].fullPath,
|
|
1001
|
+
originalPath: desc.frameReader['Lnk '].originalPath,
|
|
1002
|
+
relativePath: desc.frameReader['Lnk '].relPath,
|
|
1003
|
+
alias: desc.frameReader['Lnk '].alis,
|
|
1004
|
+
},
|
|
1005
|
+
mediaDescriptor: desc.frameReader.mediaDescriptor,
|
|
1006
|
+
},
|
|
1007
|
+
showAlteredVideo: desc.showAlteredVideo,
|
|
1008
|
+
};
|
|
1009
|
+
} else {
|
|
1010
|
+
reader.log(`Unknown pixelSourceType`);
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
(writer, target) => {
|
|
1014
|
+
const source = target.pixelSource!;
|
|
1015
|
+
const desc: PxScDescriptor = {
|
|
1016
|
+
_name: '',
|
|
1017
|
+
_classID: 'PixelSource',
|
|
1018
|
+
pixelSourceType: 1986285651, // vdP
|
|
1019
|
+
descVersion: 1,
|
|
1020
|
+
origin: { Hrzn: source.origin.x, Vrtc: source.origin.y },
|
|
1021
|
+
interpretation: {
|
|
1022
|
+
_name: '',
|
|
1023
|
+
_classID: 'footageInterpretation',
|
|
1024
|
+
Vrsn: 1,
|
|
1025
|
+
interpretAlpha: `alphaInterpretation.${source.interpretation.interpretAlpha}` as any,
|
|
1026
|
+
profile: source.interpretation.profile,
|
|
1027
|
+
},
|
|
1028
|
+
frameReader: {
|
|
1029
|
+
_name: '',
|
|
1030
|
+
_classID: 'FrameReader',
|
|
1031
|
+
frameReaderType: 1364477522, // QTF
|
|
1032
|
+
descVersion: 1,
|
|
1033
|
+
'Lnk ': {
|
|
1034
|
+
_name: '',
|
|
1035
|
+
_classID: 'ExternalFileLink',
|
|
1036
|
+
descVersion: 2,
|
|
1037
|
+
'Nm ': source.frameReader.link.name,
|
|
1038
|
+
fullPath: source.frameReader.link.fullPath,
|
|
1039
|
+
originalPath: source.frameReader.link.originalPath,
|
|
1040
|
+
alis: source.frameReader.link.alias,
|
|
1041
|
+
relPath: source.frameReader.link.relativePath,
|
|
1042
|
+
},
|
|
1043
|
+
mediaDescriptor: source.frameReader.mediaDescriptor,
|
|
1044
|
+
},
|
|
1045
|
+
showAlteredVideo: source.showAlteredVideo,
|
|
1046
|
+
};
|
|
1047
|
+
writeVersionAndDescriptor(writer, '', 'PixelSource', desc);
|
|
1048
|
+
},
|
|
1049
|
+
);
|
|
1050
|
+
|
|
981
1051
|
addHandler(
|
|
982
1052
|
'vstk',
|
|
983
1053
|
hasKey('vectorStroke'),
|
|
@@ -3627,6 +3697,8 @@ if (MOCK_HANDLERS) {
|
|
|
3627
3697
|
|
|
3628
3698
|
/*
|
|
3629
3699
|
interface CAIDesc {
|
|
3700
|
+
_name: '';
|
|
3701
|
+
_classID: 'null';
|
|
3630
3702
|
enab: boolean;
|
|
3631
3703
|
generationalGuid: string;
|
|
3632
3704
|
}
|
|
@@ -3636,15 +3708,15 @@ addHandler(
|
|
|
3636
3708
|
() => false,
|
|
3637
3709
|
(reader, _target, left) => {
|
|
3638
3710
|
const version = readUint32(reader); // 3
|
|
3639
|
-
const desc = readVersionAndDescriptor(reader) as CAIDesc;
|
|
3711
|
+
const desc = readVersionAndDescriptor(reader, true) as CAIDesc;
|
|
3712
|
+
console.log('CAI version', version);
|
|
3640
3713
|
console.log('CAI', require('util').inspect(desc, false, 99, true));
|
|
3641
|
-
console.log('CAI', { version });
|
|
3642
3714
|
console.log('CAI left', readBytes(reader, left())); // 8 bytes left, all zeroes
|
|
3643
3715
|
},
|
|
3644
3716
|
(_writer, _target) => {
|
|
3645
3717
|
},
|
|
3646
3718
|
);
|
|
3647
|
-
*/
|
|
3719
|
+
// */
|
|
3648
3720
|
|
|
3649
3721
|
if (MOCK_HANDLERS) {
|
|
3650
3722
|
addHandler(
|
|
@@ -3659,11 +3731,25 @@ if (MOCK_HANDLERS) {
|
|
|
3659
3731
|
);
|
|
3660
3732
|
}
|
|
3661
3733
|
|
|
3734
|
+
// interface OCIODescriptor {
|
|
3735
|
+
// _name: '';
|
|
3736
|
+
// _classID: 'documentColorManagementInfo';
|
|
3737
|
+
// 'Knd ': 'icc';
|
|
3738
|
+
// ocio_display_view: {
|
|
3739
|
+
// _name: '';
|
|
3740
|
+
// _classID: 'viewColorManagementInfo';
|
|
3741
|
+
// display: string;
|
|
3742
|
+
// view: string;
|
|
3743
|
+
// };
|
|
3744
|
+
// }
|
|
3745
|
+
|
|
3662
3746
|
if (MOCK_HANDLERS) {
|
|
3663
3747
|
addHandler(
|
|
3664
|
-
'OCIO', //
|
|
3748
|
+
'OCIO', // document color management info
|
|
3665
3749
|
target => (target as any)._OCIO !== undefined,
|
|
3666
3750
|
(reader, target, left) => {
|
|
3751
|
+
// const desc = readVersionAndDescriptor(reader, true) as OCIODescriptor;
|
|
3752
|
+
// console.log('OCIO', require('util').inspect(desc, false, 99, true));
|
|
3667
3753
|
(target as any)._OCIO = readBytes(reader, left());
|
|
3668
3754
|
},
|
|
3669
3755
|
(writer, target) => {
|
|
@@ -3672,8 +3758,11 @@ if (MOCK_HANDLERS) {
|
|
|
3672
3758
|
);
|
|
3673
3759
|
}
|
|
3674
3760
|
|
|
3675
|
-
// interface
|
|
3761
|
+
// interface GenIDescriptor {
|
|
3762
|
+
// _name: '';
|
|
3763
|
+
// _classID: 'genTechInfo';
|
|
3676
3764
|
// isUsingGenTech: number;
|
|
3765
|
+
// externalModelList?: [];
|
|
3677
3766
|
// }
|
|
3678
3767
|
|
|
3679
3768
|
if (MOCK_HANDLERS) {
|
|
@@ -3681,9 +3770,9 @@ if (MOCK_HANDLERS) {
|
|
|
3681
3770
|
'GenI', // generative tech
|
|
3682
3771
|
target => (target as any)._GenI !== undefined,
|
|
3683
3772
|
(reader, target, left) => {
|
|
3773
|
+
const desc = readVersionAndDescriptor(reader, true); // as GenIDescriptor;
|
|
3774
|
+
console.log('GenI', require('util').inspect(desc, false, 99, true));
|
|
3684
3775
|
(target as any)._GenI = readBytes(reader, left());
|
|
3685
|
-
// const desc = readVersionAndDescriptor(reader) as GenIDesc;
|
|
3686
|
-
// console.log('GenI', require('util').inspect(desc, false, 99, true));
|
|
3687
3776
|
},
|
|
3688
3777
|
(writer, target) => {
|
|
3689
3778
|
writeBytes(writer, (target as any)._GenI);
|
package/src/ase.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createReader, readFloat32, readSignature, readUint16, readUint32, readUnicodeStringWithLength } from './psdReader';
|
|
2
|
+
|
|
3
|
+
export type AseColorType = 'global' | 'spot' | 'normal';
|
|
4
|
+
|
|
5
|
+
export interface AseColor {
|
|
6
|
+
name: string;
|
|
7
|
+
color: {
|
|
8
|
+
r: number;
|
|
9
|
+
g: number;
|
|
10
|
+
b: number;
|
|
11
|
+
type: AseColorType;
|
|
12
|
+
} | {
|
|
13
|
+
c: number;
|
|
14
|
+
m: number;
|
|
15
|
+
y: number;
|
|
16
|
+
k: number;
|
|
17
|
+
type: AseColorType;
|
|
18
|
+
} | {
|
|
19
|
+
k: number;
|
|
20
|
+
type: AseColorType;
|
|
21
|
+
} | {
|
|
22
|
+
l: number;
|
|
23
|
+
a: number;
|
|
24
|
+
b: number;
|
|
25
|
+
type: AseColorType;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AseGroup {
|
|
30
|
+
name: string;
|
|
31
|
+
colors: AseColor[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Ase {
|
|
35
|
+
colors: (AseGroup | AseColor)[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function readAse(buffer: ArrayBufferView): Ase {
|
|
39
|
+
const reader = createReader(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
40
|
+
const signature = readSignature(reader); // ASEF
|
|
41
|
+
if (signature !== 'ASEF') throw new Error('Invalid signature');
|
|
42
|
+
const versionMajor = readUint16(reader); // 1
|
|
43
|
+
const versionMinor = readUint16(reader); // 0
|
|
44
|
+
if (versionMajor !== 1 || versionMinor !== 0) throw new Error('Invalid version');
|
|
45
|
+
const blocksCount = readUint32(reader);
|
|
46
|
+
const colorTypes: AseColorType[] = ['global', 'spot', 'normal'];
|
|
47
|
+
const ase: Ase = { colors: [] };
|
|
48
|
+
let group: Ase | AseGroup = ase;
|
|
49
|
+
|
|
50
|
+
for (let i = 0; i < blocksCount; i++) {
|
|
51
|
+
const type = readUint16(reader);
|
|
52
|
+
const length = readUint32(reader);
|
|
53
|
+
const end = reader.offset + length;
|
|
54
|
+
|
|
55
|
+
switch (type) {
|
|
56
|
+
case 0x0001: { // color
|
|
57
|
+
const nameLength = readUint16(reader);
|
|
58
|
+
const name = readUnicodeStringWithLength(reader, nameLength);
|
|
59
|
+
const colorMode = readSignature(reader);
|
|
60
|
+
let color: any;
|
|
61
|
+
switch (colorMode) {
|
|
62
|
+
case 'RGB ':
|
|
63
|
+
color = {
|
|
64
|
+
r: readFloat32(reader),
|
|
65
|
+
g: readFloat32(reader),
|
|
66
|
+
b: readFloat32(reader),
|
|
67
|
+
type: colorTypes[readUint16(reader)],
|
|
68
|
+
};
|
|
69
|
+
break;
|
|
70
|
+
case 'CMYK':
|
|
71
|
+
color = {
|
|
72
|
+
c: readFloat32(reader),
|
|
73
|
+
m: readFloat32(reader),
|
|
74
|
+
y: readFloat32(reader),
|
|
75
|
+
k: readFloat32(reader),
|
|
76
|
+
type: colorTypes[readUint16(reader)],
|
|
77
|
+
};
|
|
78
|
+
break;
|
|
79
|
+
case 'Gray':
|
|
80
|
+
color = {
|
|
81
|
+
k: readFloat32(reader),
|
|
82
|
+
type: colorTypes[readUint16(reader)],
|
|
83
|
+
};
|
|
84
|
+
break;
|
|
85
|
+
case 'LAB ':
|
|
86
|
+
color = {
|
|
87
|
+
l: readFloat32(reader),
|
|
88
|
+
a: readFloat32(reader),
|
|
89
|
+
b: readFloat32(reader),
|
|
90
|
+
type: colorTypes[readUint16(reader)],
|
|
91
|
+
};
|
|
92
|
+
break;
|
|
93
|
+
default:
|
|
94
|
+
throw new Error('Invalid color mode');
|
|
95
|
+
}
|
|
96
|
+
group.colors.push({ name, color });
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case 0xC001: { // group start
|
|
100
|
+
const nameLength = readUint16(reader);
|
|
101
|
+
const name = readUnicodeStringWithLength(reader, nameLength);
|
|
102
|
+
ase.colors.push(group = { name, colors: [] });
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case 0xC002: // group end
|
|
106
|
+
group = ase;
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
throw new Error('Invalid block type');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
reader.offset = end;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return ase;
|
|
116
|
+
}
|
package/src/descriptor.ts
CHANGED
|
@@ -1014,6 +1014,39 @@ export interface FrameListDescriptor {
|
|
|
1014
1014
|
LaSt: FrameDescriptor[];
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
1017
|
+
export interface PxScDescriptor {
|
|
1018
|
+
_name: '';
|
|
1019
|
+
_classID: 'PixelSource';
|
|
1020
|
+
pixelSourceType: 1986285651; // vdPS
|
|
1021
|
+
descVersion: 1;
|
|
1022
|
+
origin: { Hrzn: number; Vrtc: number; };
|
|
1023
|
+
interpretation: {
|
|
1024
|
+
_name: '';
|
|
1025
|
+
_classID: 'footageInterpretation';
|
|
1026
|
+
Vrsn: 1;
|
|
1027
|
+
interpretAlpha: 'alphaInterpretation.straight';
|
|
1028
|
+
profile: Uint8Array;
|
|
1029
|
+
};
|
|
1030
|
+
frameReader: {
|
|
1031
|
+
_name: '';
|
|
1032
|
+
_classID: 'FrameReader';
|
|
1033
|
+
frameReaderType: 1364477522; // QTFR
|
|
1034
|
+
descVersion: 1;
|
|
1035
|
+
'Lnk ': {
|
|
1036
|
+
_name: '';
|
|
1037
|
+
_classID: 'ExternalFileLink';
|
|
1038
|
+
descVersion: 2;
|
|
1039
|
+
'Nm ': string;
|
|
1040
|
+
fullPath: string;
|
|
1041
|
+
originalPath: string;
|
|
1042
|
+
alis: string;
|
|
1043
|
+
relPath: string;
|
|
1044
|
+
};
|
|
1045
|
+
mediaDescriptor: string;
|
|
1046
|
+
};
|
|
1047
|
+
showAlteredVideo: boolean;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1017
1050
|
export function horzVrtcToXY(hv: HrznVrtcDescriptor): { x: number; y: number; } {
|
|
1018
1051
|
return { x: hv.Hrzn, y: hv.Vrtc };
|
|
1019
1052
|
}
|
package/src/psd.ts
CHANGED
|
@@ -1488,6 +1488,26 @@ export interface LayerAdditionalInfo {
|
|
|
1488
1488
|
ranges: { sourceRange: number[]; destRange: number[]; }[];
|
|
1489
1489
|
};
|
|
1490
1490
|
vowv?: number; // ???
|
|
1491
|
+
pixelSource?: {
|
|
1492
|
+
type: 'vdPS';
|
|
1493
|
+
origin: { x: number; y: number; };
|
|
1494
|
+
interpretation: {
|
|
1495
|
+
interpretAlpha: string; // 'straight' | ...;
|
|
1496
|
+
profile: Uint8Array;
|
|
1497
|
+
};
|
|
1498
|
+
frameReader: {
|
|
1499
|
+
type: 'QTFR';
|
|
1500
|
+
link: {
|
|
1501
|
+
name: string;
|
|
1502
|
+
fullPath: string;
|
|
1503
|
+
originalPath: string;
|
|
1504
|
+
relativePath: string;
|
|
1505
|
+
alias: string;
|
|
1506
|
+
};
|
|
1507
|
+
mediaDescriptor: string;
|
|
1508
|
+
};
|
|
1509
|
+
showAlteredVideo: boolean;
|
|
1510
|
+
};
|
|
1491
1511
|
|
|
1492
1512
|
// Base64 encoded raw EngineData, currently just kept in original state to support
|
|
1493
1513
|
// loading and modifying PSD file without breaking text layers.
|