ag-psd 16.0.0 → 17.0.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/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/dist/additionalInfo.js +933 -247
- package/dist/additionalInfo.js.map +1 -1
- package/dist/bundle.js +1299 -325
- package/dist/descriptor.d.ts +140 -1
- package/dist/descriptor.js +297 -37
- package/dist/descriptor.js.map +1 -1
- package/dist/imageResources.js +13 -21
- package/dist/imageResources.js.map +1 -1
- package/dist/psd.d.ts +445 -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 +26 -7
- package/dist/psdWriter.js.map +1 -1
- package/dist-es/additionalInfo.js +934 -248
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/descriptor.d.ts +140 -1
- package/dist-es/descriptor.js +293 -38
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/imageResources.js +14 -22
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/psd.d.ts +445 -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 +22 -7
- package/dist-es/psdWriter.js.map +1 -1
- package/package.json +1 -1
- package/src/additionalInfo.ts +2014 -289
- package/src/descriptor.ts +329 -39
- package/src/imageResources.ts +18 -23
- package/src/psd.ts +477 -46
- package/src/psdReader.ts +26 -7
- package/src/psdWriter.ts +25 -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.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.boundsToDescBounds = exports.descBoundsToBounds = 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 = exports.strokeStyleLineCapType = exports.ESliceBGColorType = void 0;
|
|
15
16
|
var helpers_1 = require("./helpers");
|
|
16
17
|
var psdReader_1 = require("./psdReader");
|
|
17
18
|
var psdWriter_1 = require("./psdWriter");
|
|
@@ -106,6 +107,7 @@ var fieldToExtType = {
|
|
|
106
107
|
sheetStyle: nullType,
|
|
107
108
|
translation: nullType,
|
|
108
109
|
Skew: nullType,
|
|
110
|
+
boundingBox: makeType('', 'boundingBox'),
|
|
109
111
|
'Lnk ': makeType('', 'ExternalFileLink'),
|
|
110
112
|
frameReader: makeType('', 'FrameReader'),
|
|
111
113
|
effectParams: makeType('', 'motionTrackEffectParams'),
|
|
@@ -113,11 +115,15 @@ var fieldToExtType = {
|
|
|
113
115
|
Anch: makeType('', 'Pnt '),
|
|
114
116
|
'Fwd ': makeType('', 'Pnt '),
|
|
115
117
|
'Bwd ': makeType('', 'Pnt '),
|
|
118
|
+
FlrC: makeType('', 'Pnt '),
|
|
116
119
|
meshBoundaryPath: makeType('', 'pathClass'),
|
|
117
120
|
filterFX: makeType('', 'filterFXStyle'),
|
|
118
121
|
Fltr: makeType('', 'rigidTransform'),
|
|
119
122
|
FrgC: makeType('', 'RGBC'),
|
|
120
123
|
BckC: makeType('', 'RGBC'),
|
|
124
|
+
sdwM: makeType('Parameters', 'adaptCorrectTones'),
|
|
125
|
+
hglM: makeType('Parameters', 'adaptCorrectTones'),
|
|
126
|
+
customShape: makeType('', 'customShape'),
|
|
121
127
|
};
|
|
122
128
|
var fieldToArrayExtType = {
|
|
123
129
|
'Crv ': makeType('', 'CrPt'),
|
|
@@ -146,15 +152,20 @@ var fieldToArrayExtType = {
|
|
|
146
152
|
pathComponents: makeType('', 'PaCm'),
|
|
147
153
|
filterFXList: makeType('', 'filterFX'),
|
|
148
154
|
puppetShapeList: makeType('', 'puppetShape'),
|
|
155
|
+
channelDenoise: makeType('', 'channelDenoiseParams'),
|
|
156
|
+
ShrP: makeType('', 'Pnt '),
|
|
149
157
|
};
|
|
150
158
|
var typeToField = {
|
|
151
159
|
'TEXT': [
|
|
152
160
|
'Txt ', 'printerName', 'Nm ', 'Idnt', 'blackAndWhitePresetFileName', 'LUT3DFileName',
|
|
153
161
|
'presetFileName', 'curvesPresetFileName', 'mixerPresetFileName', 'placed', 'description', 'reason',
|
|
154
162
|
'artboardPresetName', 'json', 'clipID', 'relPath', 'fullPath', 'mediaDescriptor', 'Msge',
|
|
155
|
-
'altTag', 'url', 'cellText',
|
|
163
|
+
'altTag', 'url', 'cellText', 'preset', 'KnNm', 'FPth',
|
|
164
|
+
],
|
|
165
|
+
'tdta': [
|
|
166
|
+
'EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray',
|
|
167
|
+
'LqMe',
|
|
156
168
|
],
|
|
157
|
-
'tdta': ['EngineData', 'LUT3DFileData', 'indexArray', 'originalVertexArray', 'deformedVertexArray'],
|
|
158
169
|
'long': [
|
|
159
170
|
'TextIndex', 'RndS', 'Mdpn', 'Smth', 'Lctn', 'strokeStyleVersion', 'LaID', 'Vrsn', 'Cnt ',
|
|
160
171
|
'Brgh', 'Cntr', 'means', 'vibrance', 'Strt', 'bwPresetKind', 'presetKind', 'comp', 'compID', 'originalCompID',
|
|
@@ -165,16 +176,19 @@ var typeToField = {
|
|
|
165
176
|
'numBefore', 'numAfter', 'Spcn', 'minOpacity', 'maxOpacity', 'BlnM', 'sheetID', 'gblA', 'globalAltitude',
|
|
166
177
|
'descVersion', 'frameReaderType', 'LyrI', 'zoomOrigin', 'fontSize', 'Rds ', 'sliceID',
|
|
167
178
|
'topOutset', 'leftOutset', 'bottomOutset', 'rightOutset', 'filterID', 'meshQuality',
|
|
168
|
-
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN',
|
|
179
|
+
'meshExpansion', 'meshRigidity', 'VrsM', 'VrsN', 'NmbG', 'WLMn', 'WLMx', 'AmMn', 'AmMx', 'SclH', 'SclV',
|
|
180
|
+
'Lvl ', 'TlNm', 'TlOf', 'FlRs', 'Thsh', 'ShrS', 'ShrE', 'FlRs', 'Vrnc', 'Strg', 'ExtS', 'ExtD',
|
|
181
|
+
'HrzS', 'VrtS', 'NmbR', 'EdgF', 'Ang1', 'Ang2', 'Ang3', 'Ang4',
|
|
169
182
|
],
|
|
170
183
|
'enum': [
|
|
171
|
-
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS',
|
|
172
|
-
'
|
|
184
|
+
'textGridding', 'Ornt', 'warpStyle', 'warpRotate', 'Inte', 'Bltn', 'ClrS', 'BlrQ',
|
|
185
|
+
'bvlT', 'bvlS', 'bvlD', 'Md ', 'glwS', 'GrdF', 'GlwT', 'RplS', 'BlrM', 'SmBM',
|
|
173
186
|
'strokeStyleLineCapType', 'strokeStyleLineJoinType', 'strokeStyleLineAlignment',
|
|
174
187
|
'strokeStyleBlendMode', 'PntT', 'Styl', 'lookupType', 'LUTFormat', 'dataOrder',
|
|
175
188
|
'tableOrder', 'enableCompCore', 'enableCompCoreGPU', 'compCoreSupport', 'compCoreGPUSupport', 'Engn',
|
|
176
189
|
'enableCompCoreThreads', 'gs99', 'FrDs', 'trackID', 'animInterpStyle', 'horzAlign',
|
|
177
|
-
'vertAlign', 'bgColorType', 'shapeOperation',
|
|
190
|
+
'vertAlign', 'bgColorType', 'shapeOperation', 'UndA', 'Wvtp', 'Drct', 'WndM', 'Edg ', 'FlCl', 'IntE',
|
|
191
|
+
'IntC', 'Cnvr', 'Fl ', 'Dstr', 'MztT', 'Lns ', 'ExtT', 'DspM', 'ExtR', 'ZZTy', 'SphM', 'SmBQ',
|
|
178
192
|
],
|
|
179
193
|
'bool': [
|
|
180
194
|
'PstS', 'printSixteenBit', 'masterFXSwitch', 'enab', 'uglg', 'antialiasGloss',
|
|
@@ -186,7 +200,8 @@ var typeToField = {
|
|
|
186
200
|
'present', 'showInDialog', 'overprint', 'sheetDisclosed', 'lightsDisclosed', 'meshesDisclosed',
|
|
187
201
|
'materialsDisclosed', 'hasMotion', 'muted', 'Effc', 'selected', 'autoScope', 'fillCanvas',
|
|
188
202
|
'cellTextIsHTML', 'Smoo', 'Clsp', 'validAtPosition', 'rigidType', 'hasoptions', 'filterMaskEnable',
|
|
189
|
-
'filterMaskLinked', 'filterMaskExtendWithWhite',
|
|
203
|
+
'filterMaskLinked', 'filterMaskExtendWithWhite', 'removeJPEGArtifact', 'Mnch', 'ExtF', 'ExtM',
|
|
204
|
+
'moreAccurate', 'GpuY', 'LIWy',
|
|
190
205
|
],
|
|
191
206
|
'doub': [
|
|
192
207
|
'warpValue', 'warpPerspective', 'warpPerspectiveOther', 'Intr', 'Wdth', 'Hght',
|
|
@@ -196,10 +211,10 @@ var typeToField = {
|
|
|
196
211
|
'PuX0', 'PuX1', 'PuX2', 'PuX3', 'PuY0', 'PuY1', 'PuY2', 'PuY3'
|
|
197
212
|
],
|
|
198
213
|
'UntF': [
|
|
199
|
-
'
|
|
214
|
+
'sdwO', 'hglO', 'lagl', 'Lald', 'srgR', 'blur', 'Sftn', 'Opct', 'Dstn', 'Angl',
|
|
200
215
|
'Ckmt', 'Nose', 'Inpr', 'ShdN', 'strokeStyleLineWidth', 'strokeStyleLineDashOffset',
|
|
201
216
|
'strokeStyleOpacity', 'H ', 'Top ', 'Left', 'Btom', 'Rght', 'Rslt',
|
|
202
|
-
'topRight', 'topLeft', 'bottomLeft', 'bottomRight',
|
|
217
|
+
'topRight', 'topLeft', 'bottomLeft', 'bottomRight', 'ClNs', 'Shrp',
|
|
203
218
|
],
|
|
204
219
|
'VlLs': [
|
|
205
220
|
'Crv ', 'Clrs', 'Mnm ', 'Mxm ', 'Trns', 'pathList', 'strokeStyleLineDashSet', 'FrLs', 'slices',
|
|
@@ -207,10 +222,12 @@ var typeToField = {
|
|
|
207
222
|
'solidFillMulti', 'frameFXMulti', 'innerShadowMulti', 'dropShadowMulti', 'FrIn', 'FSts', 'FsFr',
|
|
208
223
|
'sheetTimelineOptions', 'audioClipList', 'trackList', 'globalTrackList', 'keyList', 'audioClipList',
|
|
209
224
|
'warpValues', 'selectedPin', 'Pts ', 'SbpL', 'pathComponents', 'pinOffsets', 'posFinalPins',
|
|
210
|
-
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList',
|
|
225
|
+
'pinVertexIndices', 'PinP', 'PnRt', 'PnOv', 'PnDp', 'filterFXList', 'puppetShapeList', 'ShrP',
|
|
226
|
+
'channelDenoise', 'Mtrx',
|
|
211
227
|
],
|
|
212
228
|
'ObAr': ['meshPoints', 'quiltSliceX', 'quiltSliceY'],
|
|
213
|
-
'obj ': ['null'],
|
|
229
|
+
'obj ': ['null', 'Chnl'],
|
|
230
|
+
'Pth ': ['DspF'],
|
|
214
231
|
};
|
|
215
232
|
var channels = [
|
|
216
233
|
'Rd ', 'Grn ', 'Bl ', 'Yllw', 'Ylw ', 'Cyn ', 'Mgnt', 'Blck', 'Gry ', 'Lmnc', 'A ', 'B ',
|
|
@@ -249,6 +266,9 @@ var fieldToArrayType = {
|
|
|
249
266
|
PnDp: 'doub',
|
|
250
267
|
filterFXList: 'Objc',
|
|
251
268
|
puppetShapeList: 'Objc',
|
|
269
|
+
ShrP: 'Objc',
|
|
270
|
+
channelDenoise: 'Objc',
|
|
271
|
+
Mtrx: 'long',
|
|
252
272
|
};
|
|
253
273
|
var fieldToType = {};
|
|
254
274
|
for (var _i = 0, _a = Object.keys(typeToField); _i < _a.length; _i++) {
|
|
@@ -324,11 +344,12 @@ function writeAsciiStringOrClassId(writer, value) {
|
|
|
324
344
|
}
|
|
325
345
|
}
|
|
326
346
|
function readDescriptorStructure(reader) {
|
|
327
|
-
|
|
328
|
-
// object.__struct =
|
|
347
|
+
// const struct =
|
|
329
348
|
readClassStructure(reader);
|
|
349
|
+
// const object: any = { _name: struct.name, _classID: struct.classID };
|
|
350
|
+
var object = {};
|
|
351
|
+
// console.log('>> ', struct);
|
|
330
352
|
var itemsCount = (0, psdReader_1.readUint32)(reader);
|
|
331
|
-
// console.log('//', object.__struct);
|
|
332
353
|
for (var i = 0; i < itemsCount; i++) {
|
|
333
354
|
var key = readAsciiStringOrClassId(reader);
|
|
334
355
|
var type = (0, psdReader_1.readSignature)(reader);
|
|
@@ -347,21 +368,63 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
347
368
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
|
|
348
369
|
writeAsciiStringOrClassId(writer, classId);
|
|
349
370
|
var keys = Object.keys(value);
|
|
350
|
-
|
|
371
|
+
var keyCount = keys.length;
|
|
372
|
+
if ('_name' in value)
|
|
373
|
+
keyCount--;
|
|
374
|
+
if ('_classID' in value)
|
|
375
|
+
keyCount--;
|
|
376
|
+
(0, psdWriter_1.writeUint32)(writer, keyCount);
|
|
351
377
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
352
378
|
var key = keys_1[_i];
|
|
379
|
+
if (key === '_name' || key === '_classID')
|
|
380
|
+
continue;
|
|
353
381
|
var type = getTypeByKey(key, value[key], root, value);
|
|
354
382
|
var extType = fieldToExtType[key];
|
|
355
|
-
if (key === '
|
|
383
|
+
if (key === 'bounds' && root === 'text') {
|
|
384
|
+
extType = makeType('', 'bounds');
|
|
385
|
+
}
|
|
386
|
+
else if (key === 'origin') {
|
|
356
387
|
type = root === 'slices' ? 'enum' : 'Objc';
|
|
357
388
|
}
|
|
389
|
+
else if ((key === 'Cyn ' || key === 'Mgnt' || key === 'Ylw ' || key === 'Blck') && value._classID === 'CMYC') {
|
|
390
|
+
type = 'doub';
|
|
391
|
+
}
|
|
392
|
+
else if (/^PN[a-z][a-z]$/.test(key)) {
|
|
393
|
+
type = 'TEXT';
|
|
394
|
+
}
|
|
395
|
+
else if (/^PT[a-z][a-z]$/.test(key)) {
|
|
396
|
+
type = 'long';
|
|
397
|
+
}
|
|
398
|
+
else if (/^PF[a-z][a-z]$/.test(key)) {
|
|
399
|
+
type = 'doub';
|
|
400
|
+
}
|
|
401
|
+
else if (key === 'ClSz' || key === 'Rds ' || key === 'Amnt') {
|
|
402
|
+
type = typeof value[key] === 'number' ? 'long' : 'UntF';
|
|
403
|
+
}
|
|
404
|
+
else if ((key === 'sdwM' || key === 'hglM') && typeof value[key] === 'string') {
|
|
405
|
+
type = 'enum';
|
|
406
|
+
}
|
|
407
|
+
else if (key === 'blur' && typeof value[key] === 'string') {
|
|
408
|
+
type = 'enum';
|
|
409
|
+
}
|
|
410
|
+
else if (key === 'Angl' && typeof value[key] === 'number') {
|
|
411
|
+
type = 'doub'; // ???
|
|
412
|
+
}
|
|
358
413
|
else if (key === 'bounds' && root === 'slices') {
|
|
359
414
|
type = 'Objc';
|
|
360
415
|
extType = makeType('', 'Rct1');
|
|
361
416
|
}
|
|
362
|
-
else if (key === 'Scl '
|
|
363
|
-
|
|
364
|
-
|
|
417
|
+
else if (key === 'Scl ') {
|
|
418
|
+
if (typeof value[key] === 'object' && 'Hrzn' in value[key]) {
|
|
419
|
+
type = 'Objc';
|
|
420
|
+
extType = nullType;
|
|
421
|
+
}
|
|
422
|
+
else if (typeof value[key] === 'number') {
|
|
423
|
+
type = 'long';
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
type = 'UntF';
|
|
427
|
+
}
|
|
365
428
|
}
|
|
366
429
|
else if (key === 'audioClipGroupList' && keys.length === 1) {
|
|
367
430
|
type = 'VlLs';
|
|
@@ -369,7 +432,13 @@ function writeDescriptorStructure(writer, name, classId, value, root) {
|
|
|
369
432
|
else if ((key === 'Strt' || key === 'Brgh') && 'H ' in value) {
|
|
370
433
|
type = 'doub';
|
|
371
434
|
}
|
|
372
|
-
else if (key === '
|
|
435
|
+
else if (key === 'Wdth' && typeof value[key] === 'object') {
|
|
436
|
+
type = 'UntF';
|
|
437
|
+
}
|
|
438
|
+
else if (key === 'Ofst' && typeof value[key] === 'number') {
|
|
439
|
+
type = 'long';
|
|
440
|
+
}
|
|
441
|
+
else if (key === 'Strt' && typeof value[key] === 'object') {
|
|
373
442
|
type = 'Objc';
|
|
374
443
|
extType = nullType;
|
|
375
444
|
}
|
|
@@ -489,11 +558,11 @@ function readOSType(reader, type) {
|
|
|
489
558
|
return items;
|
|
490
559
|
}
|
|
491
560
|
case 'Pth ': { // File path
|
|
492
|
-
/*const length =*/ (0, psdReader_1.readInt32)(reader);
|
|
561
|
+
/*const length =*/ (0, psdReader_1.readInt32)(reader); // total size of all fields below
|
|
493
562
|
var sig = (0, psdReader_1.readSignature)(reader);
|
|
494
|
-
/*const pathSize =*/ (0, psdReader_1.readInt32LE)(reader);
|
|
563
|
+
/*const pathSize =*/ (0, psdReader_1.readInt32LE)(reader); // the same as length
|
|
495
564
|
var charsCount = (0, psdReader_1.readInt32LE)(reader);
|
|
496
|
-
var path = (0, psdReader_1.
|
|
565
|
+
var path = (0, psdReader_1.readUnicodeStringWithLengthLE)(reader, charsCount);
|
|
497
566
|
return { sig: sig, path: path };
|
|
498
567
|
}
|
|
499
568
|
default:
|
|
@@ -511,12 +580,19 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
511
580
|
writeReferenceStructure(writer, key, value);
|
|
512
581
|
break;
|
|
513
582
|
case 'Objc': // Descriptor
|
|
514
|
-
case 'GlbO': // GlobalObject same as Descriptor
|
|
583
|
+
case 'GlbO': { // GlobalObject same as Descriptor
|
|
584
|
+
if (typeof value !== 'object')
|
|
585
|
+
throw new Error("Invalid struct value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
515
586
|
if (!extType)
|
|
516
587
|
throw new Error("Missing ext type for: '".concat(key, "' (").concat(JSON.stringify(value), ")"));
|
|
517
|
-
|
|
588
|
+
var name_1 = value._name || extType.name;
|
|
589
|
+
var classID = value._classID || extType.classID;
|
|
590
|
+
writeDescriptorStructure(writer, name_1, classID, value, root);
|
|
518
591
|
break;
|
|
592
|
+
}
|
|
519
593
|
case 'VlLs': // List
|
|
594
|
+
if (!Array.isArray(value))
|
|
595
|
+
throw new Error("Invalid list value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
520
596
|
(0, psdWriter_1.writeInt32)(writer, value.length);
|
|
521
597
|
for (var i = 0; i < value.length; i++) {
|
|
522
598
|
var type_3 = fieldToArrayType[key];
|
|
@@ -527,6 +603,8 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
527
603
|
}
|
|
528
604
|
break;
|
|
529
605
|
case 'doub': // Double
|
|
606
|
+
if (typeof value !== 'number')
|
|
607
|
+
throw new Error("Invalid number value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
530
608
|
(0, psdWriter_1.writeFloat64)(writer, value);
|
|
531
609
|
break;
|
|
532
610
|
case 'UntF': // Unit double
|
|
@@ -545,17 +623,23 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
545
623
|
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, value);
|
|
546
624
|
break;
|
|
547
625
|
case 'enum': { // Enumerated
|
|
626
|
+
if (typeof value !== 'string')
|
|
627
|
+
throw new Error("Invalid enum value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
548
628
|
var _a = value.split('.'), _type = _a[0], val = _a[1];
|
|
549
629
|
writeAsciiStringOrClassId(writer, _type);
|
|
550
630
|
writeAsciiStringOrClassId(writer, val);
|
|
551
631
|
break;
|
|
552
632
|
}
|
|
553
633
|
case 'long': // Integer
|
|
634
|
+
if (typeof value !== 'number')
|
|
635
|
+
throw new Error("Invalid integer value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
554
636
|
(0, psdWriter_1.writeInt32)(writer, value);
|
|
555
637
|
break;
|
|
556
638
|
// case 'comp': // Large Integer
|
|
557
639
|
// writeLargeInteger(reader);
|
|
558
640
|
case 'bool': // Boolean
|
|
641
|
+
if (typeof value !== 'boolean')
|
|
642
|
+
throw new Error("Invalid boolean value: ".concat(JSON.stringify(value), ", key: ").concat(key));
|
|
559
643
|
(0, psdWriter_1.writeUint8)(writer, value ? 1 : 0);
|
|
560
644
|
break;
|
|
561
645
|
// case 'type': // Class
|
|
@@ -586,8 +670,15 @@ function writeOSType(writer, type, value, key, extType, root) {
|
|
|
586
670
|
}
|
|
587
671
|
break;
|
|
588
672
|
}
|
|
589
|
-
|
|
590
|
-
|
|
673
|
+
case 'Pth ': { // File path
|
|
674
|
+
var length_5 = 4 + 4 + 4 + value.path.length * 2;
|
|
675
|
+
(0, psdWriter_1.writeInt32)(writer, length_5);
|
|
676
|
+
(0, psdWriter_1.writeSignature)(writer, value.sig);
|
|
677
|
+
(0, psdWriter_1.writeInt32LE)(writer, length_5);
|
|
678
|
+
(0, psdWriter_1.writeInt32LE)(writer, value.path.length);
|
|
679
|
+
(0, psdWriter_1.writeUnicodeStringWithoutLengthLE)(writer, value.path);
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
591
682
|
default:
|
|
592
683
|
throw new Error("Not implemented descriptor OSType: ".concat(type));
|
|
593
684
|
}
|
|
@@ -678,7 +769,6 @@ function writeReferenceStructure(writer, _key, items) {
|
|
|
678
769
|
function readClassStructure(reader) {
|
|
679
770
|
var name = (0, psdReader_1.readUnicodeString)(reader);
|
|
680
771
|
var classID = readAsciiStringOrClassId(reader);
|
|
681
|
-
// console.log({ name, classID });
|
|
682
772
|
return { name: name, classID: classID };
|
|
683
773
|
}
|
|
684
774
|
function writeClassStructure(writer, name, classID) {
|
|
@@ -708,6 +798,26 @@ function xyToHorzVrtc(xy) {
|
|
|
708
798
|
return { Hrzn: xy.x, Vrtc: xy.y };
|
|
709
799
|
}
|
|
710
800
|
exports.xyToHorzVrtc = xyToHorzVrtc;
|
|
801
|
+
function descBoundsToBounds(desc) {
|
|
802
|
+
return {
|
|
803
|
+
top: parseUnits(desc['Top ']),
|
|
804
|
+
left: parseUnits(desc.Left),
|
|
805
|
+
right: parseUnits(desc.Rght),
|
|
806
|
+
bottom: parseUnits(desc.Btom),
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
exports.descBoundsToBounds = descBoundsToBounds;
|
|
810
|
+
function boundsToDescBounds(bounds) {
|
|
811
|
+
var _a;
|
|
812
|
+
return _a = {
|
|
813
|
+
Left: unitsValue(bounds.left, 'bounds.left')
|
|
814
|
+
},
|
|
815
|
+
_a['Top '] = unitsValue(bounds.top, 'bounds.top'),
|
|
816
|
+
_a.Rght = unitsValue(bounds.right, 'bounds.right'),
|
|
817
|
+
_a.Btom = unitsValue(bounds.bottom, 'bounds.bottom'),
|
|
818
|
+
_a;
|
|
819
|
+
}
|
|
820
|
+
exports.boundsToDescBounds = boundsToDescBounds;
|
|
711
821
|
function parseFxObject(fx) {
|
|
712
822
|
var stroke = {
|
|
713
823
|
enabled: !!fx.enab,
|
|
@@ -858,7 +968,8 @@ function parseKeyList(keyList, logMissingFeatures) {
|
|
|
858
968
|
var keys = [];
|
|
859
969
|
for (var j = 0; j < keyList.length; j++) {
|
|
860
970
|
var key = keyList[j];
|
|
861
|
-
var
|
|
971
|
+
var _a = key.time, denominator = _a.denominator, numerator = _a.numerator, selected = key.selected, animKey = key.animKey;
|
|
972
|
+
var time = { numerator: numerator, denominator: denominator };
|
|
862
973
|
var interpolation = exports.animInterpStyleEnum.decode(key.animInterpStyle);
|
|
863
974
|
switch (animKey.Type) {
|
|
864
975
|
case 'keyType.Opct':
|
|
@@ -1107,6 +1218,9 @@ function parseEffectObject(obj, reportErrors) {
|
|
|
1107
1218
|
case 'antialiasGloss':
|
|
1108
1219
|
result[key] = val;
|
|
1109
1220
|
break;
|
|
1221
|
+
case '_name':
|
|
1222
|
+
case '_classID':
|
|
1223
|
+
break;
|
|
1110
1224
|
default:
|
|
1111
1225
|
reportErrors && console.log("Invalid effect key: '".concat(key, "', value:"), val);
|
|
1112
1226
|
}
|
|
@@ -1459,25 +1573,25 @@ function parseColor(color) {
|
|
|
1459
1573
|
exports.parseColor = parseColor;
|
|
1460
1574
|
function serializeColor(color) {
|
|
1461
1575
|
if (!color) {
|
|
1462
|
-
return { 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1576
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': 0, 'Grn ': 0, 'Bl ': 0 };
|
|
1463
1577
|
}
|
|
1464
1578
|
else if ('r' in color) {
|
|
1465
|
-
return { 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1579
|
+
return { _name: '', _classID: 'RGBC', 'Rd ': color.r || 0, 'Grn ': color.g || 0, 'Bl ': color.b || 0 };
|
|
1466
1580
|
}
|
|
1467
1581
|
else if ('fr' in color) {
|
|
1468
|
-
return { redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1582
|
+
return { _name: '', _classID: 'XXXX', redFloat: color.fr, greenFloat: color.fg, blueFloat: color.fb };
|
|
1469
1583
|
}
|
|
1470
1584
|
else if ('h' in color) {
|
|
1471
|
-
return { 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1585
|
+
return { _name: '', _classID: 'HSBC', 'H ': unitsAngle(color.h * 360), Strt: color.s || 0, Brgh: color.b || 0 };
|
|
1472
1586
|
}
|
|
1473
1587
|
else if ('c' in color) {
|
|
1474
|
-
return { 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1588
|
+
return { _name: '', _classID: 'CMYC', 'Cyn ': color.c || 0, Mgnt: color.m || 0, 'Ylw ': color.y || 0, Blck: color.k || 0 };
|
|
1475
1589
|
}
|
|
1476
1590
|
else if ('l' in color) {
|
|
1477
|
-
return { Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1591
|
+
return { _name: '', _classID: 'LABC', Lmnc: color.l || 0, 'A ': color.a || 0, 'B ': color.b || 0 };
|
|
1478
1592
|
}
|
|
1479
1593
|
else if ('k' in color) {
|
|
1480
|
-
return { 'Gry ': color.k };
|
|
1594
|
+
return { _name: '', _classID: 'GRYC', 'Gry ': color.k };
|
|
1481
1595
|
}
|
|
1482
1596
|
else {
|
|
1483
1597
|
throw new Error('Invalid color value');
|
|
@@ -1541,6 +1655,10 @@ function unitsPercent(value) {
|
|
|
1541
1655
|
return { units: 'Percent', value: Math.round((value || 0) * 100) };
|
|
1542
1656
|
}
|
|
1543
1657
|
exports.unitsPercent = unitsPercent;
|
|
1658
|
+
function unitsPercentF(value) {
|
|
1659
|
+
return { units: 'Percent', value: (value || 0) * 100 };
|
|
1660
|
+
}
|
|
1661
|
+
exports.unitsPercentF = unitsPercentF;
|
|
1544
1662
|
function unitsValue(x, key) {
|
|
1545
1663
|
if (x == null)
|
|
1546
1664
|
return { units: 'Pixels', value: 0 };
|
|
@@ -1556,6 +1674,11 @@ function unitsValue(x, key) {
|
|
|
1556
1674
|
return { units: units, value: value };
|
|
1557
1675
|
}
|
|
1558
1676
|
exports.unitsValue = unitsValue;
|
|
1677
|
+
function frac(_a) {
|
|
1678
|
+
var numerator = _a.numerator, denominator = _a.denominator;
|
|
1679
|
+
return { numerator: numerator, denominator: denominator };
|
|
1680
|
+
}
|
|
1681
|
+
exports.frac = frac;
|
|
1559
1682
|
exports.textGridding = (0, helpers_1.createEnum)('textGridding', 'none', {
|
|
1560
1683
|
none: 'None',
|
|
1561
1684
|
round: 'Rnd ',
|
|
@@ -1677,6 +1800,7 @@ exports.ClrS = (0, helpers_1.createEnum)('ClrS', 'rgb', {
|
|
|
1677
1800
|
rgb: 'RGBC',
|
|
1678
1801
|
hsb: 'HSBl',
|
|
1679
1802
|
lab: 'LbCl',
|
|
1803
|
+
hsl: 'HSLC',
|
|
1680
1804
|
});
|
|
1681
1805
|
exports.FStl = (0, helpers_1.createEnum)('FStl', 'outside', {
|
|
1682
1806
|
outside: 'OutF',
|
|
@@ -1723,4 +1847,140 @@ exports.strokeStyleLineAlignment = (0, helpers_1.createEnum)('strokeStyleLineAli
|
|
|
1723
1847
|
center: 'strokeStyleAlignCenter',
|
|
1724
1848
|
outside: 'strokeStyleAlignOutside',
|
|
1725
1849
|
});
|
|
1850
|
+
exports.BlrM = (0, helpers_1.createEnum)('BlrM', 'ispinmage', {
|
|
1851
|
+
spin: 'Spn ',
|
|
1852
|
+
zoom: 'Zm ',
|
|
1853
|
+
});
|
|
1854
|
+
exports.BlrQ = (0, helpers_1.createEnum)('BlrQ', 'good', {
|
|
1855
|
+
draft: 'Drft',
|
|
1856
|
+
good: 'Gd ',
|
|
1857
|
+
best: 'Bst ',
|
|
1858
|
+
});
|
|
1859
|
+
exports.SmBM = (0, helpers_1.createEnum)('SmBM', 'normal', {
|
|
1860
|
+
normal: 'SBMN',
|
|
1861
|
+
'edge only': 'SBME',
|
|
1862
|
+
'overlay edge': 'SBMO',
|
|
1863
|
+
});
|
|
1864
|
+
exports.SmBQ = (0, helpers_1.createEnum)('SmBQ', 'medium', {
|
|
1865
|
+
low: 'SBQL',
|
|
1866
|
+
medium: 'SBQM',
|
|
1867
|
+
high: 'SBQH',
|
|
1868
|
+
});
|
|
1869
|
+
exports.DspM = (0, helpers_1.createEnum)('DspM', 'stretch to fit', {
|
|
1870
|
+
'stretch to fit': 'StrF',
|
|
1871
|
+
'tile': 'Tile',
|
|
1872
|
+
});
|
|
1873
|
+
exports.UndA = (0, helpers_1.createEnum)('UndA', 'repeat edge pixels', {
|
|
1874
|
+
'wrap around': 'WrpA',
|
|
1875
|
+
'repeat edge pixels': 'RptE',
|
|
1876
|
+
});
|
|
1877
|
+
exports.Cnvr = (0, helpers_1.createEnum)('Cnvr', 'rectangular to polar', {
|
|
1878
|
+
'rectangular to polar': 'RctP',
|
|
1879
|
+
'polar to rectangular': 'PlrR',
|
|
1880
|
+
});
|
|
1881
|
+
exports.RplS = (0, helpers_1.createEnum)('RplS', 'medium', {
|
|
1882
|
+
small: 'Sml ',
|
|
1883
|
+
medium: 'Mdm ',
|
|
1884
|
+
large: 'Lrg ',
|
|
1885
|
+
});
|
|
1886
|
+
exports.SphM = (0, helpers_1.createEnum)('SphM', 'normal', {
|
|
1887
|
+
'normal': 'Nrml',
|
|
1888
|
+
'horizontal only': 'HrzO',
|
|
1889
|
+
'vertical only': 'VrtO',
|
|
1890
|
+
});
|
|
1891
|
+
exports.Wvtp = (0, helpers_1.createEnum)('Wvtp', 'sine', {
|
|
1892
|
+
sine: 'WvSn',
|
|
1893
|
+
triangle: 'WvTr',
|
|
1894
|
+
square: 'WvSq',
|
|
1895
|
+
});
|
|
1896
|
+
exports.ZZTy = (0, helpers_1.createEnum)('ZZTy', 'pond ripples', {
|
|
1897
|
+
'around center': 'ArnC',
|
|
1898
|
+
'out from center': 'OtFr',
|
|
1899
|
+
'pond ripples': 'PndR',
|
|
1900
|
+
});
|
|
1901
|
+
exports.Dstr = (0, helpers_1.createEnum)('Dstr', 'uniform', {
|
|
1902
|
+
uniform: 'Unfr',
|
|
1903
|
+
gaussian: 'Gsn ',
|
|
1904
|
+
});
|
|
1905
|
+
exports.Chnl = (0, helpers_1.createEnum)('Chnl', 'composite', {
|
|
1906
|
+
red: 'Rd ',
|
|
1907
|
+
green: 'Grn ',
|
|
1908
|
+
blue: 'Bl ',
|
|
1909
|
+
composite: 'Cmps',
|
|
1910
|
+
});
|
|
1911
|
+
exports.MztT = (0, helpers_1.createEnum)('MztT', 'fine dots', {
|
|
1912
|
+
'fine dots': 'FnDt',
|
|
1913
|
+
'medium dots': 'MdmD',
|
|
1914
|
+
'grainy dots': 'GrnD',
|
|
1915
|
+
'coarse dots': 'CrsD',
|
|
1916
|
+
'short lines': 'ShrL',
|
|
1917
|
+
'medium lines': 'MdmL',
|
|
1918
|
+
'long lines': 'LngL',
|
|
1919
|
+
'short strokes': 'ShSt',
|
|
1920
|
+
'medium strokes': 'MdmS',
|
|
1921
|
+
'long strokes': 'LngS',
|
|
1922
|
+
});
|
|
1923
|
+
exports.Lns = (0, helpers_1.createEnum)('Lns ', '50-300mm zoom', {
|
|
1924
|
+
'50-300mm zoom': 'Zm ',
|
|
1925
|
+
'32mm prime': 'Nkn ',
|
|
1926
|
+
'105mm prime': 'Nkn1',
|
|
1927
|
+
'movie prime': 'PnVs',
|
|
1928
|
+
});
|
|
1929
|
+
exports.blurType = (0, helpers_1.createEnum)('blurType', 'gaussian blur', {
|
|
1930
|
+
'gaussian blur': 'GsnB',
|
|
1931
|
+
'lens blur': 'lensBlur',
|
|
1932
|
+
'motion blur': 'MtnB',
|
|
1933
|
+
});
|
|
1934
|
+
exports.DfsM = (0, helpers_1.createEnum)('DfsM', 'normal', {
|
|
1935
|
+
'normal': 'Nrml',
|
|
1936
|
+
'darken only': 'DrkO',
|
|
1937
|
+
'lighten only': 'LghO',
|
|
1938
|
+
'anisotropic': 'anisotropic',
|
|
1939
|
+
});
|
|
1940
|
+
exports.ExtT = (0, helpers_1.createEnum)('ExtT', 'blocks', {
|
|
1941
|
+
blocks: 'Blks',
|
|
1942
|
+
pyramids: 'Pyrm',
|
|
1943
|
+
});
|
|
1944
|
+
exports.ExtR = (0, helpers_1.createEnum)('ExtR', 'random', {
|
|
1945
|
+
random: 'Rndm',
|
|
1946
|
+
'level-based': 'LvlB',
|
|
1947
|
+
});
|
|
1948
|
+
exports.FlCl = (0, helpers_1.createEnum)('FlCl', 'background color', {
|
|
1949
|
+
'background color': 'FlBc',
|
|
1950
|
+
'foreground color': 'FlFr',
|
|
1951
|
+
'inverse image': 'FlIn',
|
|
1952
|
+
'unaltered image': 'FlSm',
|
|
1953
|
+
});
|
|
1954
|
+
exports.CntE = (0, helpers_1.createEnum)('CntE', 'upper', {
|
|
1955
|
+
lower: 'Lwr ',
|
|
1956
|
+
upper: 'Upr ',
|
|
1957
|
+
});
|
|
1958
|
+
exports.WndM = (0, helpers_1.createEnum)('WndM', 'wind', {
|
|
1959
|
+
wind: 'Wnd ',
|
|
1960
|
+
blast: 'Blst',
|
|
1961
|
+
stagger: 'Stgr',
|
|
1962
|
+
});
|
|
1963
|
+
exports.Drct = (0, helpers_1.createEnum)('Drct', 'from the right', {
|
|
1964
|
+
left: 'Left',
|
|
1965
|
+
right: 'Rght',
|
|
1966
|
+
});
|
|
1967
|
+
exports.IntE = (0, helpers_1.createEnum)('IntE', 'odd lines', {
|
|
1968
|
+
'odd lines': 'ElmO',
|
|
1969
|
+
'even lines': 'ElmE',
|
|
1970
|
+
});
|
|
1971
|
+
exports.IntC = (0, helpers_1.createEnum)('IntC', 'interpolation', {
|
|
1972
|
+
duplication: 'CrtD',
|
|
1973
|
+
interpolation: 'CrtI',
|
|
1974
|
+
});
|
|
1975
|
+
exports.FlMd = (0, helpers_1.createEnum)('FlMd', 'wrap around', {
|
|
1976
|
+
'set to transparent': 'Bckg',
|
|
1977
|
+
'repeat edge pixels': 'Rpt ',
|
|
1978
|
+
'wrap around': 'Wrp ',
|
|
1979
|
+
});
|
|
1980
|
+
exports.prjM = (0, helpers_1.createEnum)('prjM', 'fisheye', {
|
|
1981
|
+
'fisheye': 'fisP',
|
|
1982
|
+
'perspective': 'perP',
|
|
1983
|
+
'auto': 'auto',
|
|
1984
|
+
'full spherical': 'fusP',
|
|
1985
|
+
});
|
|
1726
1986
|
//# sourceMappingURL=descriptor.js.map
|