ag-psd 16.0.0 → 17.0.0
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 +5 -0
- package/README.md +1 -0
- package/dist/additionalInfo.js +927 -238
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +1263 -311
- package/dist/descriptor.d.ts +129 -0
- package/dist/descriptor.js +272 -36
- package/dist/descriptor.js.map +1 -1
- package/dist/imageResources.js +9 -17
- package/dist/imageResources.js.map +1 -1
- package/dist/psd.d.ts +437 -62
- package/dist/psdReader.d.ts +2 -0
- package/dist/psdReader.js +30 -13
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +4 -0
- package/dist/psdWriter.js +25 -7
- package/dist/psdWriter.js.map +1 -1
- package/dist-es/additionalInfo.js +928 -239
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/descriptor.d.ts +129 -0
- package/dist-es/descriptor.js +270 -37
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/imageResources.js +10 -18
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/psd.d.ts +437 -62
- package/dist-es/psdReader.d.ts +2 -0
- package/dist-es/psdReader.js +27 -12
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +4 -0
- package/dist-es/psdWriter.js +21 -7
- package/dist-es/psdWriter.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +2008 -288
- package/src/descriptor.ts +297 -37
- package/src/imageResources.ts +14 -19
- package/src/psd.ts +467 -46
- package/src/psdReader.ts +26 -7
- package/src/psdWriter.ts +24 -8
package/dist/descriptor.js
CHANGED
|
@@ -11,7 +11,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.strokeStyleLineCapType = exports.ESliceBGColorType = exports.ESliceOrigin = exports.ESliceVertAlign = exports.ESliceHorzAlign = exports.ESliceType = exports.FrFl = exports.FStl = exports.ClrS = exports.gradientInterpolationMethodType = exports.stdTrackID = exports.animInterpStyleEnum = exports.GrdT = exports.IGSr = exports.BETE = exports.BESs = exports.bvlT = exports.BESl = exports.BlnM = exports.warpStyle = exports.Annt = exports.Ornt = exports.textGridding = exports.frac = exports.unitsValue = exports.unitsPercentF = exports.unitsPercent = exports.unitsAngle = exports.parseUnitsToNumber = exports.parseUnitsOrNumber = exports.parseUnits = exports.parsePercentOrAngle = exports.parsePercent = exports.parseAngle = exports.serializeColor = exports.parseColor = exports.serializeVectorContent = exports.parseVectorContent = exports.serializeTrackList = exports.parseTrackList = exports.parseEffects = exports.serializeEffects = exports.xyToHorzVrtc = exports.horzVrtcToXY = exports.writeVersionAndDescriptor = exports.readVersionAndDescriptor = exports.writeDescriptorStructure = exports.readDescriptorStructure = exports.readAsciiStringOrClassId = exports.setLogErrors = void 0;
|
|
15
|
+
exports.prjM = exports.FlMd = exports.IntC = exports.IntE = exports.Drct = exports.WndM = exports.CntE = exports.FlCl = exports.ExtR = exports.ExtT = exports.DfsM = exports.blurType = exports.Lns = exports.MztT = exports.Chnl = exports.Dstr = exports.ZZTy = exports.Wvtp = exports.SphM = exports.RplS = exports.Cnvr = exports.UndA = exports.DspM = exports.SmBQ = exports.SmBM = exports.BlrQ = exports.BlrM = exports.strokeStyleLineAlignment = exports.strokeStyleLineJoinType = void 0;
|
|
15
16
|
var helpers_1 = require("./helpers");
|
|
16
17
|
var psdReader_1 = require("./psdReader");
|
|
17
18
|
var psdWriter_1 = require("./psdWriter");
|
|
@@ -113,11 +114,15 @@ var fieldToExtType = {
|
|
|
113
114
|
Anch: makeType('', 'Pnt '),
|
|
114
115
|
'Fwd ': makeType('', 'Pnt '),
|
|
115
116
|
'Bwd ': makeType('', 'Pnt '),
|
|
117
|
+
FlrC: makeType('', 'Pnt '),
|
|
116
118
|
meshBoundaryPath: makeType('', 'pathClass'),
|
|
117
119
|
filterFX: makeType('', 'filterFXStyle'),
|
|
118
120
|
Fltr: makeType('', 'rigidTransform'),
|
|
119
121
|
FrgC: makeType('', 'RGBC'),
|
|
120
122
|
BckC: makeType('', 'RGBC'),
|
|
123
|
+
sdwM: makeType('Parameters', 'adaptCorrectTones'),
|
|
124
|
+
hglM: makeType('Parameters', 'adaptCorrectTones'),
|
|
125
|
+
customShape: makeType('', 'customShape'),
|
|
121
126
|
};
|
|
122
127
|
var fieldToArrayExtType = {
|
|
123
128
|
'Crv ': makeType('', 'CrPt'),
|
|
@@ -146,15 +151,20 @@ var fieldToArrayExtType = {
|
|
|
146
151
|
pathComponents: makeType('', 'PaCm'),
|
|
147
152
|
filterFXList: makeType('', 'filterFX'),
|
|
148
153
|
puppetShapeList: makeType('', 'puppetShape'),
|
|
154
|
+
channelDenoise: makeType('', 'channelDenoiseParams'),
|
|
155
|
+
ShrP: makeType('', 'Pnt '),
|
|
149
156
|
};
|
|
150
157
|
var typeToField = {
|
|
151
158
|
'TEXT': [
|
|
152
159
|
'Txt ', 'printerName', 'Nm ', 'Idnt', 'blackAndWhitePresetFileName', 'LUT3DFileName',
|
|
153
160
|
'presetFileName', 'curvesPresetFileName', 'mixerPresetFileName', 'placed', 'description', 'reason',
|
|
154
161
|
'artboardPresetName', 'json', 'clipID', 'relPath', 'fullPath', 'mediaDescriptor', 'Msge',
|
|
155
|
-
'altTag', 'url', 'cellText',
|
|
162
|
+
'altTag', 'url', 'cellText', 'preset', 'KnNm', 'FPth',
|
|
163
|
+
],
|
|
164
|
+
'tdta': [
|
|
165
|
+
'EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray',
|
|
166
|
+
'LqMe',
|
|
156
167
|
],
|
|
157
|
-
'tdta': ['EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray'],
|
|
158
168
|
'long': [
|
|
159
169
|
'TextIndex', 'RndS', 'Mdpn', 'Smth', 'Lctn', 'strokeStyleVersion', 'LaID', 'Vrsn', 'Cnt ',
|
|
160
170
|
'Brgh', 'Cntr', 'means', 'vibrance', 'Strt', 'bwPresetKind', 'presetKind', 'comp', 'compID', 'originalCompID',
|
|
@@ -165,16 +175,19 @@ var typeToField = {
|
|
|
165
175
|
'numBefore', 'numAfter', 'Spcn', 'minOpacity', 'maxOpacity', 'BlnM', 'sheetID', 'gblA', 'globalAltitude',
|
|
166
176
|
'descVersion', 'frameReaderType', 'LyrI', 'zoomOrigin', 'fontSize', 'Rds ', 'sliceID',
|
|
167
177
|
'topOutset', 'leftOutset', 'bottomOutset', 'rightOutset', 'filterID', 'meshQuality',
|
|
168
|
-
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN',
|
|
178
|
+
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN', 'NmbG', 'WLMn', 'WLMx', 'AmMn', 'AmMx', 'SclH', 'SclV',
|
|
179
|
+
'Lvl ', 'TlNm', 'TlOf', 'FlRs', 'Thsh', 'ShrS', 'ShrE', 'FlRs', 'Vrnc', 'Strg', 'ExtS', 'ExtD',
|
|
180
|
+
'HrzS', 'VrtS', 'NmbR', 'EdgF', 'Ang1', 'Ang2', 'Ang3', 'Ang4',
|
|
169
181
|
],
|
|
170
182
|
'enum': [
|
|
171
|
-
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS',
|
|
172
|
-
'
|
|
183
|
+
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS', 'BlrQ',
|
|
184
|
+
'bvlT', 'bvlS', 'bvlD', 'Md ', 'glwS', 'GrdF', 'GlwT', 'RplS', 'BlrM', 'SmBM',
|
|
173
185
|
'strokeStyleLineCapType', 'strokeStyleLineJoinType', 'strokeStyleLineAlignment',
|
|
174
186
|
'strokeStyleBlendMode', 'PntT', 'Styl', 'lookupType', 'LUTFormat', 'dataOrder',
|
|
175
187
|
'tableOrder', 'enableCompCore', 'enableCompCoreGPU', 'compCoreSupport', 'compCoreGPUSupport', 'Engn',
|
|
176
188
|
'enableCompCoreThreads', 'gs99', 'FrDs', 'trackID', 'animInterpStyle', 'horzAlign',
|
|
177
|
-
'vertAlign', 'bgColorType', 'shapeOperation',
|
|
189
|
+
'vertAlign', 'bgColorType', 'shapeOperation', 'UndA', 'Wvtp', 'Drct', 'WndM', 'Edg ', 'FlCl', 'IntE',
|
|
190
|
+
'IntC', 'Cnvr', 'Fl ', 'Dstr', 'MztT', 'Lns ', 'ExtT', 'DspM', 'ExtR', 'ZZTy', 'SphM', 'SmBQ',
|
|
178
191
|
],
|
|
179
192
|
'bool': [
|
|
180
193
|
'PstS', 'printSixteenBit', 'masterFXSwitch', 'enab', 'uglg', 'antialiasGloss',
|
|
@@ -186,7 +199,8 @@ var typeToField = {
|
|
|
186
199
|
'present', 'showInDialog', 'overprint', 'sheetDisclosed', 'lightsDisclosed', 'meshesDisclosed',
|
|
187
200
|
'materialsDisclosed', 'hasMotion', 'muted', 'Effc', 'selected', 'autoScope', 'fillCanvas',
|
|
188
201
|
'cellTextIsHTML', 'Smoo', 'Clsp', 'validAtPosition', 'rigidType', 'hasoptions', 'filterMaskEnable',
|
|
189
|
-
'filterMaskLinked', 'filterMaskExtendWithWhite',
|
|
202
|
+
'filterMaskLinked', 'filterMaskExtendWithWhite', 'removeJPEGArtifact', 'Mnch', 'ExtF', 'ExtM',
|
|
203
|
+
'moreAccurate', 'GpuY', 'LIWy',
|
|
190
204
|
],
|
|
191
205
|
'doub': [
|
|
192
206
|
'warpValue', 'warpPerspective', 'warpPerspectiveOther', 'Intr', 'Wdth', 'Hght',
|
|
@@ -196,10 +210,10 @@ var typeToField = {
|
|
|
196
210
|
'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3'
|
|
197
211
|
],
|
|
198
212
|
'UntF': [
|
|
199
|
-
'
|
|
213
|
+
'sdwO', 'hglO', 'lagl', 'Lald', 'srgR', 'blur', 'Sftn', 'Opct', 'Dstn', 'Angl',
|
|
200
214
|
'Ckmt', 'Nose', 'Inpr', 'ShdN', 'strokeStyleLineWidth', 'strokeStyleLineDashOffset',
|
|
201
215
|
'strokeStyleOpacity', 'H ', 'Top ', 'Left', 'Btom', 'Rght', 'Rslt',
|
|
202
|
-
'topRight', 'topLeft', 'bottomLeft', 'bottomRight',
|
|
216
|
+
'topRight', 'topLeft', 'bottomLeft', 'bottomRight', 'ClNs', 'Shrp',
|
|
203
217
|
],
|
|
204
218
|
'VlLs': [
|
|
205
219
|
'Crv ', 'Clrs', 'Mnm ', 'Mxm ', 'Trns', 'pathList', 'strokeStyleLineDashSet', 'FrLs', 'slices',
|
|
@@ -207,10 +221,12 @@ var typeToField = {
|
|
|
207
221
|
'solidFillMulti', 'frameFXMulti', 'innerShadowMulti', 'dropShadowMulti', 'FrIn', 'FSts', 'FsFr',
|
|
208
222
|
'sheetTimelineOptions', 'audioClipList', 'trackList', 'globalTrackList', 'keyList', 'audioClipList',
|
|
209
223
|
'warpValues', 'selectedPin', 'Pts ', 'SbpL', 'pathComponents', 'pinOffsets', 'posFinalPins',
|
|
210
|
-
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList',
|
|
224
|
+
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList', 'ShrP',
|
|
225
|
+
'channelDenoise', 'Mtrx',
|
|
211
226
|
],
|
|
212
227
|
'ObAr': ['meshPoints', 'quiltSliceX', 'quiltSliceY'],
|
|
213
|
-
'obj ': ['null'],
|
|
228
|
+
'obj ': ['null', 'Chnl'],
|
|
229
|
+
'Pth ': ['DspF'],
|
|
214
230
|
};
|
|
215
231
|
var channels = [
|
|
216
232
|
'Rd ', 'Grn ', 'Bl ', 'Yllw', 'Ylw ', 'Cyn ', 'Mgnt', 'Blck', 'Gry ', 'Lmnc', 'A ', 'B ',
|
|
@@ -249,6 +265,9 @@ var fieldToArrayType = {
|
|
|
249
265
|
PnDp: 'doub',
|
|
250
266
|
filterFXList: 'Objc',
|
|
251
267
|
puppetShapeList: 'Objc',
|
|
268
|
+
ShrP: 'Objc',
|
|
269
|
+
channelDenoise: 'Objc',
|
|
270
|
+
Mtrx: 'long',
|
|
252
271
|
};
|
|
253
272
|
var fieldToType = {};
|
|
254
273
|
for (var _i = 0, _a = Object.keys(typeToField); _i < _a.length; _i++) {
|
|
@@ -324,11 +343,12 @@ function writeAsciiStringOrClassId(writer, value) {
|
|
|
324
343
|
}
|
|
325
344
|
}
|
|
326
345
|
function readDescriptorStructure(reader) {
|
|
327
|
-
|
|
328
|
-
// object.__struct =
|
|
346
|
+
// const struct =
|
|
329
347
|
readClassStructure(reader);
|
|
348
|
+
// const object: any = { _name: struct.name, _classID: struct.classID };
|
|
349
|
+
var object = {};
|
|
350
|
+
// console.log('>> ', struct);
|
|
330
351
|
var itemsCount = (0, psdReader_1.readUint32)(reader);
|
|
331
|
-
// console.log('//', object.__struct);
|
|
332
352
|
for (var i = 0; i < itemsCount; i++) {
|
|
333
353
|
var key = readAsciiStringOrClassId(reader);
|
|
334
354
|
var type = (0, psdReader_1.readSignature)(reader);
|
|
@@ -347,21 +367,60 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
347
367
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
|
|
348
368
|
writeAsciiStringOrClassId(writer, classId);
|
|
349
369
|
var keys = Object.keys(value);
|
|
350
|
-
|
|
370
|
+
var keyCount = keys.length;
|
|
371
|
+
if ('_name' in value)
|
|
372
|
+
keyCount--;
|
|
373
|
+
if ('_classID' in value)
|
|
374
|
+
keyCount--;
|
|
375
|
+
(0, psdWriter_1.writeUint32)(writer, keyCount);
|
|
351
376
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
352
377
|
var key = keys_1[_i];
|
|
378
|
+
if (key === '_name' || key === '_classID')
|
|
379
|
+
continue;
|
|
353
380
|
var type = getTypeByKey(key, value[key], root, value);
|
|
354
381
|
var extType = fieldToExtType[key];
|
|
355
382
|
if (key === 'origin') {
|
|
356
383
|
type = root === 'slices' ? 'enum' : 'Objc';
|
|
357
384
|
}
|
|
385
|
+
else if ((key === 'Cyn ' || key === 'Mgnt' || key === 'Ylw ' || key === 'Blck') && value._classID === 'CMYC') {
|
|
386
|
+
type = 'doub';
|
|
387
|
+
}
|
|
388
|
+
else if (/^PN[a-z][a-z]$/.test(key)) {
|
|
389
|
+
type = 'TEXT';
|
|
390
|
+
}
|
|
391
|
+
else if (/^PT[a-z][a-z]$/.test(key)) {
|
|
392
|
+
type = 'long';
|
|
393
|
+
}
|
|
394
|
+
else if (/^PF[a-z][a-z]$/.test(key)) {
|
|
395
|
+
type = 'doub';
|
|
396
|
+
}
|
|
397
|
+
else if (key === 'ClSz' || key === 'Rds ' || key === 'Amnt') {
|
|
398
|
+
type = typeof value[key] === 'number' ? 'long' : 'UntF';
|
|
399
|
+
}
|
|
400
|
+
else if ((key === 'sdwM' || key === 'hglM') && typeof value[key] === 'string') {
|
|
401
|
+
type = 'enum';
|
|
402
|
+
}
|
|
403
|
+
else if (key === 'blur' && typeof value[key] === 'string') {
|
|
404
|
+
type = 'enum';
|
|
405
|
+
}
|
|
406
|
+
else if (key === 'Angl' && typeof value[key] === 'number') {
|
|
407
|
+
type = 'doub'; // ???
|
|
408
|
+
}
|
|
358
409
|
else if (key === 'bounds' && root === 'slices') {
|
|
359
410
|
type = 'Objc';
|
|
360
411
|
extType = makeType('', 'Rct1');
|
|
361
412
|
}
|
|
362
|
-
else if (key === 'Scl '
|
|
363
|
-
|
|
364
|
-
|
|
413
|
+
else if (key === 'Scl ') {
|
|
414
|
+
if (typeof value[key] === 'object' && 'Hrzn' in value[key]) {
|
|
415
|
+
type = 'Objc';
|
|
416
|
+
extType = nullType;
|
|
417
|
+
}
|
|
418
|
+
else if (typeof value[key] === 'number') {
|
|
419
|
+
type = 'long';
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
type = 'UntF';
|
|
423
|
+
}
|
|
365
424
|
}
|
|
366
425
|
else if (key === 'audioClipGroupList' && keys.length === 1) {
|
|
367
426
|
type = 'VlLs';
|
|
@@ -369,7 +428,13 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
369
428
|
else if ((key === 'Strt' || key === 'Brgh') && 'H ' in value) {
|
|
370
429
|
type = 'doub';
|
|
371
430
|
}
|
|
372
|
-
else if (key === '
|
|
431
|
+
else if (key === 'Wdth' && typeof value[key] === 'object') {
|
|
432
|
+
type = 'UntF';
|
|
433
|
+
}
|
|
434
|
+
else if (key === 'Ofst' && typeof value[key] === 'number') {
|
|
435
|
+
type = 'long';
|
|
436
|
+
}
|
|
437
|
+
else if (key === 'Strt' && typeof value[key] === 'object') {
|
|
373
438
|
type = 'Objc';
|
|
374
439
|
extType = nullType;
|
|
375
440
|
}
|
|
@@ -489,11 +554,11 @@ function readOSType(reader, type) {
|
|
|
489
554
|
return items;
|
|
490
555
|
}
|
|
491
556
|
case 'Pth ': { // File path
|
|
492
|
-
/*const length =*/ (0, psdReader_1.readInt32)(reader);
|
|
557
|
+
/*const length =*/ (0, psdReader_1.readInt32)(reader); // total size of all fields below
|
|
493
558
|
var sig = (0, psdReader_1.readSignature)(reader);
|
|
494
|
-
/*const pathSize =*/ (0, psdReader_1.readInt32LE)(reader);
|
|
559
|
+
/*const pathSize =*/ (0, psdReader_1.readInt32LE)(reader); // the same as length
|
|
495
560
|
var charsCount = (0, psdReader_1.readInt32LE)(reader);
|
|
496
|
-
var path = (0, psdReader_1.
|
|
561
|
+
var path = (0, psdReader_1.readUnicodeStringWithLengthLE)(reader, charsCount);
|
|
497
562
|
return { sig: sig, path: path };
|
|
498
563
|
}
|
|
499
564
|
default:
|
|
@@ -511,12 +576,19 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
511
576
|
writeReferenceStructure(writer, key, value);
|
|
512
577
|
break;
|
|
513
578
|
case 'Objc': // Descriptor
|
|
514
|
-
case 'GlbO': // GlobalObject same as Descriptor
|
|
579
|
+
case 'GlbO': { // GlobalObject same as Descriptor
|
|
580
|
+
if (typeof value !== 'object')
|
|
581
|
+
throw new Error("Invalid struct value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
515
582
|
if (!extType)
|
|
516
583
|
throw new Error("Missing ext type for: '".concat(key, "' (").concat(JSON.stringify(value), ")"));
|
|
517
|
-
|
|
584
|
+
var name_1 = value._name || extType.name;
|
|
585
|
+
var classID = value._classID || extType.classID;
|
|
586
|
+
writeDescriptorStructure(writer, name_1, classID, value, root);
|
|
518
587
|
break;
|
|
588
|
+
}
|
|
519
589
|
case 'VlLs': // List
|
|
590
|
+
if (!Array.isArray(value))
|
|
591
|
+
throw new Error("Invalid list value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
520
592
|
(0, psdWriter_1.writeInt32)(writer, value.length);
|
|
521
593
|
for (var i = 0; i < value.length; i++) {
|
|
522
594
|
var type_3 = fieldToArrayType[key];
|
|
@@ -527,6 +599,8 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
527
599
|
}
|
|
528
600
|
break;
|
|
529
601
|
case 'doub': // Double
|
|
602
|
+
if (typeof value !== 'number')
|
|
603
|
+
throw new Error("Invalid number value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
530
604
|
(0, psdWriter_1.writeFloat64)(writer, value);
|
|
531
605
|
break;
|
|
532
606
|
case 'UntF': // Unit double
|
|
@@ -545,17 +619,23 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
545
619
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, value);
|
|
546
620
|
break;
|
|
547
621
|
case 'enum': { // Enumerated
|
|
622
|
+
if (typeof value !== 'string')
|
|
623
|
+
throw new Error("Invalid enum value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
548
624
|
var _a = value.split('.'), _type = _a[0], val = _a[1];
|
|
549
625
|
writeAsciiStringOrClassId(writer, _type);
|
|
550
626
|
writeAsciiStringOrClassId(writer, val);
|
|
551
627
|
break;
|
|
552
628
|
}
|
|
553
629
|
case 'long': // Integer
|
|
630
|
+
if (typeof value !== 'number')
|
|
631
|
+
throw new Error("Invalid integer value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
554
632
|
(0, psdWriter_1.writeInt32)(writer, value);
|
|
555
633
|
break;
|
|
556
634
|
// case 'comp': // Large Integer
|
|
557
635
|
// writeLargeInteger(reader);
|
|
558
636
|
case 'bool': // Boolean
|
|
637
|
+
if (typeof value !== 'boolean')
|
|
638
|
+
throw new Error("Invalid boolean value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
559
639
|
(0, psdWriter_1.writeUint8)(writer, value ? 1 : 0);
|
|
560
640
|
break;
|
|
561
641
|
// case 'type': // Class
|
|
@@ -586,8 +666,15 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
586
666
|
}
|
|
587
667
|
break;
|
|
588
668
|
}
|
|
589
|
-
|
|
590
|
-
|
|
669
|
+
case 'Pth ': { // File path
|
|
670
|
+
var length_5 = 4 + 4 + 4 + value.path.length * 2;
|
|
671
|
+
(0, psdWriter_1.writeInt32)(writer, length_5);
|
|
672
|
+
(0, psdWriter_1.writeSignature)(writer, value.sig);
|
|
673
|
+
(0, psdWriter_1.writeInt32LE)(writer, length_5);
|
|
674
|
+
(0, psdWriter_1.writeInt32LE)(writer, value.path.length);
|
|
675
|
+
(0, psdWriter_1.writeUnicodeStringWithoutLengthLE)(writer, value.path);
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
591
678
|
default:
|
|
592
679
|
throw new Error("Not implemented descriptor OSType: ".concat(type));
|
|
593
680
|
}
|
|
@@ -678,7 +765,6 @@ function writeReferenceStructure(writer, _key, items) {
|
|
|
678
765
|
function readClassStructure(reader) {
|
|
679
766
|
var name = (0, psdReader_1.readUnicodeString)(reader);
|
|
680
767
|
var classID = readAsciiStringOrClassId(reader);
|
|
681
|
-
// console.log({ name, classID });
|
|
682
768
|
return { name: name, classID: classID };
|
|
683
769
|
}
|
|
684
770
|
function writeClassStructure(writer, name, classID) {
|
|
@@ -858,7 +944,8 @@ function parseKeyList(keyList, logMissingFeatures) {
|
|
|
858
944
|
var keys = [];
|
|
859
945
|
for (var j = 0; j < keyList.length; j++) {
|
|
860
946
|
var key = keyList[j];
|
|
861
|
-
var
|
|
947
|
+
var _a = key.time, denominator = _a.denominator, numerator = _a.numerator, selected = key.selected, animKey = key.animKey;
|
|
948
|
+
var time = { numerator: numerator, denominator: denominator };
|
|
862
949
|
var interpolation = exports.animInterpStyleEnum.decode(key.animInterpStyle);
|
|
863
950
|
switch (animKey.Type) {
|
|
864
951
|
case 'keyType.Opct':
|
|
@@ -1107,6 +1194,9 @@ function parseEffectObject(obj, reportErrors) {
|
|
|
1107
1194
|
case 'antialiasGloss':
|
|
1108
1195
|
result[key] = val;
|
|
1109
1196
|
break;
|
|
1197
|
+
case '_name':
|
|
1198
|
+
case '_classID':
|
|
1199
|
+
break;
|
|
1110
1200
|
default:
|
|
1111
1201
|
reportErrors && console.log("Invalid effect key: '".concat(key, "', value:"), val);
|
|
1112
1202
|
}
|
|
@@ -1459,25 +1549,25 @@ function parseColor(color) {
|
|
|
1459
1549
|
exports.parseColor = parseColor;
|
|
1460
1550
|
function serializeColor(color) {
|
|
1461
1551
|
if (!color) {
|
|
1462
|
-
return { 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1552
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1463
1553
|
}
|
|
1464
1554
|
else if ('r' in color) {
|
|
1465
|
-
return { 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1555
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1466
1556
|
}
|
|
1467
1557
|
else if ('fr' in color) {
|
|
1468
|
-
return { redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1558
|
+
return { _name: '', _classID: 'XXXX', redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1469
1559
|
}
|
|
1470
1560
|
else if ('h' in color) {
|
|
1471
|
-
return { 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1561
|
+
return { _name: '', _classID: 'HSBC', 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1472
1562
|
}
|
|
1473
1563
|
else if ('c' in color) {
|
|
1474
|
-
return { 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1564
|
+
return { _name: '', _classID: 'CMYC', 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1475
1565
|
}
|
|
1476
1566
|
else if ('l' in color) {
|
|
1477
|
-
return { Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1567
|
+
return { _name: '', _classID: 'LABC', Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1478
1568
|
}
|
|
1479
1569
|
else if ('k' in color) {
|
|
1480
|
-
return { 'Gry ': color.k };
|
|
1570
|
+
return { _name: '', _classID: 'GRYC', 'Gry ': color.k };
|
|
1481
1571
|
}
|
|
1482
1572
|
else {
|
|
1483
1573
|
throw new Error('Invalid color value');
|
|
@@ -1541,6 +1631,10 @@ function unitsPercent(value) {
|
|
|
1541
1631
|
return { units: 'Percent', value: Math.round((value || 0) * 100) };
|
|
1542
1632
|
}
|
|
1543
1633
|
exports.unitsPercent = unitsPercent;
|
|
1634
|
+
function unitsPercentF(value) {
|
|
1635
|
+
return { units: 'Percent', value: (value || 0) * 100 };
|
|
1636
|
+
}
|
|
1637
|
+
exports.unitsPercentF = unitsPercentF;
|
|
1544
1638
|
function unitsValue(x, key) {
|
|
1545
1639
|
if (x == null)
|
|
1546
1640
|
return { units: 'Pixels', value: 0 };
|
|
@@ -1556,6 +1650,11 @@ function unitsValue(x, key) {
|
|
|
1556
1650
|
return { units: units, value: value };
|
|
1557
1651
|
}
|
|
1558
1652
|
exports.unitsValue = unitsValue;
|
|
1653
|
+
function frac(_a) {
|
|
1654
|
+
var numerator = _a.numerator, denominator = _a.denominator;
|
|
1655
|
+
return { numerator: numerator, denominator: denominator };
|
|
1656
|
+
}
|
|
1657
|
+
exports.frac = frac;
|
|
1559
1658
|
exports.textGridding = (0, helpers_1.createEnum)('textGridding', 'none', {
|
|
1560
1659
|
none: 'None',
|
|
1561
1660
|
round: 'Rnd ',
|
|
@@ -1677,6 +1776,7 @@ exports.ClrS = (0, helpers_1.createEnum)('ClrS', 'rgb', {
|
|
|
1677
1776
|
rgb: 'RGBC',
|
|
1678
1777
|
hsb: 'HSBl',
|
|
1679
1778
|
lab: 'LbCl',
|
|
1779
|
+
hsl: 'HSLC',
|
|
1680
1780
|
});
|
|
1681
1781
|
exports.FStl = (0, helpers_1.createEnum)('FStl', 'outside', {
|
|
1682
1782
|
outside: 'OutF',
|
|
@@ -1723,4 +1823,140 @@ exports.strokeStyleLineAlignment = (0, helpers_1.createEnum)('strokeStyleLineAli
|
|
|
1723
1823
|
center: 'strokeStyleAlignCenter',
|
|
1724
1824
|
outside: 'strokeStyleAlignOutside',
|
|
1725
1825
|
});
|
|
1826
|
+
exports.BlrM = (0, helpers_1.createEnum)('BlrM', 'ispinmage', {
|
|
1827
|
+
spin: 'Spn ',
|
|
1828
|
+
zoom: 'Zm ',
|
|
1829
|
+
});
|
|
1830
|
+
exports.BlrQ = (0, helpers_1.createEnum)('BlrQ', 'good', {
|
|
1831
|
+
draft: 'Drft',
|
|
1832
|
+
good: 'Gd ',
|
|
1833
|
+
best: 'Bst ',
|
|
1834
|
+
});
|
|
1835
|
+
exports.SmBM = (0, helpers_1.createEnum)('SmBM', 'normal', {
|
|
1836
|
+
normal: 'SBMN',
|
|
1837
|
+
'edge only': 'SBME',
|
|
1838
|
+
'overlay edge': 'SBMO',
|
|
1839
|
+
});
|
|
1840
|
+
exports.SmBQ = (0, helpers_1.createEnum)('SmBQ', 'medium', {
|
|
1841
|
+
low: 'SBQL',
|
|
1842
|
+
medium: 'SBQM',
|
|
1843
|
+
high: 'SBQH',
|
|
1844
|
+
});
|
|
1845
|
+
exports.DspM = (0, helpers_1.createEnum)('DspM', 'stretch to fit', {
|
|
1846
|
+
'stretch to fit': 'StrF',
|
|
1847
|
+
'tile': 'Tile',
|
|
1848
|
+
});
|
|
1849
|
+
exports.UndA = (0, helpers_1.createEnum)('UndA', 'repeat edge pixels', {
|
|
1850
|
+
'wrap around': 'WrpA',
|
|
1851
|
+
'repeat edge pixels': 'RptE',
|
|
1852
|
+
});
|
|
1853
|
+
exports.Cnvr = (0, helpers_1.createEnum)('Cnvr', 'rectangular to polar', {
|
|
1854
|
+
'rectangular to polar': 'RctP',
|
|
1855
|
+
'polar to rectangular': 'PlrR',
|
|
1856
|
+
});
|
|
1857
|
+
exports.RplS = (0, helpers_1.createEnum)('RplS', 'medium', {
|
|
1858
|
+
small: 'Sml ',
|
|
1859
|
+
medium: 'Mdm ',
|
|
1860
|
+
large: 'Lrg ',
|
|
1861
|
+
});
|
|
1862
|
+
exports.SphM = (0, helpers_1.createEnum)('SphM', 'normal', {
|
|
1863
|
+
'normal': 'Nrml',
|
|
1864
|
+
'horizontal only': 'HrzO',
|
|
1865
|
+
'vertical only': 'VrtO',
|
|
1866
|
+
});
|
|
1867
|
+
exports.Wvtp = (0, helpers_1.createEnum)('Wvtp', 'sine', {
|
|
1868
|
+
sine: 'WvSn',
|
|
1869
|
+
triangle: 'WvTr',
|
|
1870
|
+
square: 'WvSq',
|
|
1871
|
+
});
|
|
1872
|
+
exports.ZZTy = (0, helpers_1.createEnum)('ZZTy', 'pond ripples', {
|
|
1873
|
+
'around center': 'ArnC',
|
|
1874
|
+
'out from center': 'OtFr',
|
|
1875
|
+
'pond ripples': 'PndR',
|
|
1876
|
+
});
|
|
1877
|
+
exports.Dstr = (0, helpers_1.createEnum)('Dstr', 'uniform', {
|
|
1878
|
+
uniform: 'Unfr',
|
|
1879
|
+
gaussian: 'Gsn ',
|
|
1880
|
+
});
|
|
1881
|
+
exports.Chnl = (0, helpers_1.createEnum)('Chnl', 'composite', {
|
|
1882
|
+
red: 'Rd ',
|
|
1883
|
+
green: 'Grn ',
|
|
1884
|
+
blue: 'Bl ',
|
|
1885
|
+
composite: 'Cmps',
|
|
1886
|
+
});
|
|
1887
|
+
exports.MztT = (0, helpers_1.createEnum)('MztT', 'fine dots', {
|
|
1888
|
+
'fine dots': 'FnDt',
|
|
1889
|
+
'medium dots': 'MdmD',
|
|
1890
|
+
'grainy dots': 'GrnD',
|
|
1891
|
+
'coarse dots': 'CrsD',
|
|
1892
|
+
'short lines': 'ShrL',
|
|
1893
|
+
'medium lines': 'MdmL',
|
|
1894
|
+
'long lines': 'LngL',
|
|
1895
|
+
'short strokes': 'ShSt',
|
|
1896
|
+
'medium strokes': 'MdmS',
|
|
1897
|
+
'long strokes': 'LngS',
|
|
1898
|
+
});
|
|
1899
|
+
exports.Lns = (0, helpers_1.createEnum)('Lns ', '50-300mm zoom', {
|
|
1900
|
+
'50-300mm zoom': 'Zm ',
|
|
1901
|
+
'32mm prime': 'Nkn ',
|
|
1902
|
+
'105mm prime': 'Nkn1',
|
|
1903
|
+
'movie prime': 'PnVs',
|
|
1904
|
+
});
|
|
1905
|
+
exports.blurType = (0, helpers_1.createEnum)('blurType', 'gaussian blur', {
|
|
1906
|
+
'gaussian blur': 'GsnB',
|
|
1907
|
+
'lens blur': 'lensBlur',
|
|
1908
|
+
'motion blur': 'MtnB',
|
|
1909
|
+
});
|
|
1910
|
+
exports.DfsM = (0, helpers_1.createEnum)('DfsM', 'normal', {
|
|
1911
|
+
'normal': 'Nrml',
|
|
1912
|
+
'darken only': 'DrkO',
|
|
1913
|
+
'lighten only': 'LghO',
|
|
1914
|
+
'anisotropic': 'anisotropic',
|
|
1915
|
+
});
|
|
1916
|
+
exports.ExtT = (0, helpers_1.createEnum)('ExtT', 'blocks', {
|
|
1917
|
+
blocks: 'Blks',
|
|
1918
|
+
pyramids: 'Pyrm',
|
|
1919
|
+
});
|
|
1920
|
+
exports.ExtR = (0, helpers_1.createEnum)('ExtR', 'random', {
|
|
1921
|
+
random: 'Rndm',
|
|
1922
|
+
'level-based': 'LvlB',
|
|
1923
|
+
});
|
|
1924
|
+
exports.FlCl = (0, helpers_1.createEnum)('FlCl', 'background color', {
|
|
1925
|
+
'background color': 'FlBc',
|
|
1926
|
+
'foreground color': 'FlFr',
|
|
1927
|
+
'inverse image': 'FlIn',
|
|
1928
|
+
'unaltered image': 'FlSm',
|
|
1929
|
+
});
|
|
1930
|
+
exports.CntE = (0, helpers_1.createEnum)('CntE', 'upper', {
|
|
1931
|
+
lower: 'Lwr ',
|
|
1932
|
+
upper: 'Upr ',
|
|
1933
|
+
});
|
|
1934
|
+
exports.WndM = (0, helpers_1.createEnum)('WndM', 'wind', {
|
|
1935
|
+
wind: 'Wnd ',
|
|
1936
|
+
blast: 'Blst',
|
|
1937
|
+
stagger: 'Stgr',
|
|
1938
|
+
});
|
|
1939
|
+
exports.Drct = (0, helpers_1.createEnum)('Drct', 'from the right', {
|
|
1940
|
+
left: 'Left',
|
|
1941
|
+
right: 'Rght',
|
|
1942
|
+
});
|
|
1943
|
+
exports.IntE = (0, helpers_1.createEnum)('IntE', 'odd lines', {
|
|
1944
|
+
'odd lines': 'ElmO',
|
|
1945
|
+
'even lines': 'ElmE',
|
|
1946
|
+
});
|
|
1947
|
+
exports.IntC = (0, helpers_1.createEnum)('IntC', 'interpolation', {
|
|
1948
|
+
duplication: 'CrtD',
|
|
1949
|
+
interpolation: 'CrtI',
|
|
1950
|
+
});
|
|
1951
|
+
exports.FlMd = (0, helpers_1.createEnum)('FlMd', 'wrap around', {
|
|
1952
|
+
'set to transparent': 'Bckg',
|
|
1953
|
+
'repeat edge pixels': 'Rpt ',
|
|
1954
|
+
'wrap around': 'Wrp ',
|
|
1955
|
+
});
|
|
1956
|
+
exports.prjM = (0, helpers_1.createEnum)('prjM', 'fisheye', {
|
|
1957
|
+
'fisheye': 'fisP',
|
|
1958
|
+
'perspective': 'perP',
|
|
1959
|
+
'auto': 'auto',
|
|
1960
|
+
'full spherical': 'fusP',
|
|
1961
|
+
});
|
|
1726
1962
|
//# sourceMappingURL=descriptor.js.map
|