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.
@@ -20,6 +20,7 @@ var psdWriter_1 = require("./psdWriter");
20
20
  var descriptor_1 = require("./descriptor");
21
21
  var engineData_1 = require("./engineData");
22
22
  var text_1 = require("./text");
23
+ var fromAtoZ = 'abcdefghijklmnopqrstuvwxyz';
23
24
  exports.infoHandlers = [];
24
25
  exports.infoHandlersMap = {};
25
26
  function addHandler(key, has, read, write) {
@@ -546,10 +547,10 @@ addHandler('shmd', function (target) { return target.timestamp !== undefined ||
546
547
  var timeScope = desc.timeScope;
547
548
  // console.log('tmln', target.name, target.id, require('util').inspect(desc, false, 99, true));
548
549
  var timeline = {
549
- start: timeScope.Strt,
550
- duration: timeScope.duration,
551
- inTime: timeScope.inTime,
552
- outTime: timeScope.outTime,
550
+ start: (0, descriptor_1.frac)(timeScope.Strt),
551
+ duration: (0, descriptor_1.frac)(timeScope.duration),
552
+ inTime: (0, descriptor_1.frac)(timeScope.inTime),
553
+ outTime: (0, descriptor_1.frac)(timeScope.outTime),
553
554
  autoScope: desc.autoScope,
554
555
  audioLevel: desc.audioLevel,
555
556
  };
@@ -690,7 +691,7 @@ addHandler('vstk', hasKey('vectorStroke'), function (reader, target, left) {
690
691
  }, function (writer, target) {
691
692
  var _a, _b, _c;
692
693
  var stroke = target.vectorStroke;
693
- var descriptor = {
694
+ var desc = {
694
695
  strokeStyleVersion: 2,
695
696
  strokeEnabled: !!stroke.strokeEnabled,
696
697
  fillEnabled: !!stroke.fillEnabled,
@@ -708,7 +709,7 @@ addHandler('vstk', hasKey('vectorStroke'), function (reader, target, left) {
708
709
  strokeStyleContent: (0, descriptor_1.serializeVectorContent)(stroke.content || { type: 'color', color: { r: 0, g: 0, b: 0 } }).descriptor,
709
710
  strokeStyleResolution: (_c = stroke.resolution) !== null && _c !== void 0 ? _c : 72,
710
711
  };
711
- (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'strokeStyle', descriptor);
712
+ (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'strokeStyle', desc);
712
713
  });
713
714
  addHandler('artb', // per-layer arboard info
714
715
  hasKey('artboard'), function (reader, target, left) {
@@ -773,7 +774,7 @@ function isQuiltWarp(warp) {
773
774
  }
774
775
  function encodeWarp(warp) {
775
776
  var bounds = warp.bounds;
776
- var desc = __assign(__assign({ warpStyle: descriptor_1.warpStyle.encode(warp.style) }, (warp.values ? { warpValues: warp.values } : { warpValue: warp.value })), { warpPerspective: warp.perspective || 0, warpPerspectiveOther: warp.perspectiveOther || 0, warpRotate: descriptor_1.Ornt.encode(warp.rotate), bounds: {
777
+ var desc = __assign(__assign({ warpStyle: descriptor_1.warpStyle.encode(warp.style) }, (warp.values ? { warpValues: warp.values } : { warpValue: warp.value || 0 })), { warpPerspective: warp.perspective || 0, warpPerspectiveOther: warp.perspectiveOther || 0, warpRotate: descriptor_1.Ornt.encode(warp.rotate), bounds: {
777
778
  'Top ': (0, descriptor_1.unitsValue)(bounds && bounds.top || { units: 'Pixels', value: 0 }, 'bounds.top'),
778
779
  Left: (0, descriptor_1.unitsValue)(bounds && bounds.left || { units: 'Pixels', value: 0 }, 'bounds.left'),
779
780
  Btom: (0, descriptor_1.unitsValue)(bounds && bounds.bottom || { units: 'Pixels', value: 0 }, 'bounds.bottom'),
@@ -791,6 +792,8 @@ function encodeWarp(warp) {
791
792
  if (isQuilt) {
792
793
  var desc2 = desc;
793
794
  desc2.customEnvelopeWarp = {
795
+ _name: '',
796
+ _classID: 'customEnvelopeWarp',
794
797
  quiltSliceX: [{
795
798
  type: 'quiltSliceX',
796
799
  values: customEnvelopeWarp.quiltSliceX || [],
@@ -807,6 +810,8 @@ function encodeWarp(warp) {
807
810
  }
808
811
  else {
809
812
  desc.customEnvelopeWarp = {
813
+ _name: '',
814
+ _classID: 'customEnvelopeWarp',
810
815
  meshPoints: [
811
816
  { type: 'Hrzn', values: meshPoints.map(function (p) { return p.x; }) },
812
817
  { type: 'Vrtc', values: meshPoints.map(function (p) { return p.y; }) },
@@ -898,58 +903,345 @@ function hrznVrtcToPoint(desc) {
898
903
  }
899
904
  function pointToHrznVrtc(point) {
900
905
  return {
906
+ _name: '',
907
+ _classID: 'Pnt ',
901
908
  Hrzn: (0, descriptor_1.unitsValue)(point.x, 'x'),
902
909
  Vrtc: (0, descriptor_1.unitsValue)(point.y, 'y'),
903
910
  };
904
911
  }
905
- function parseFilterFXFilter(Fltr) {
906
- if ('puppetShapeList' in Fltr) {
907
- return {
908
- rigidType: Fltr.rigidType,
909
- bounds: [
910
- { x: Fltr.PuX0, y: Fltr.PuY0, },
911
- { x: Fltr.PuX1, y: Fltr.PuY1, },
912
- { x: Fltr.PuX2, y: Fltr.PuY2, },
913
- { x: Fltr.PuX3, y: Fltr.PuY3, },
914
- ],
915
- puppetShapeList: Fltr.puppetShapeList.map(function (p) { return ({
916
- rigidType: p.rigidType,
917
- // TODO: VrsM
918
- // TODO: VrsN
919
- originalVertexArray: uint8ToPoints(p.originalVertexArray),
920
- deformedVertexArray: uint8ToPoints(p.deformedVertexArray),
921
- indexArray: Array.from(uint8ToUint32(p.indexArray)),
922
- pinOffsets: arrayToPoints(p.pinOffsets),
923
- posFinalPins: arrayToPoints(p.posFinalPins),
924
- pinVertexIndices: p.pinVertexIndices,
925
- selectedPin: p.selectedPin,
926
- pinPosition: arrayToPoints(p.PinP),
927
- pinRotation: p.PnRt,
928
- pinOverlay: p.PnOv,
929
- pinDepth: p.PnDp,
930
- meshQuality: p.meshQuality,
931
- meshExpansion: p.meshExpansion,
932
- meshRigidity: p.meshRigidity,
933
- imageResolution: p.imageResolution,
934
- meshBoundaryPath: {
935
- pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
936
- shapeOperation: c.shapeOperation.split('.')[1],
937
- paths: c.SbpL.map(function (t) { return ({
938
- closed: t.Clsp,
939
- points: t['Pts '].map(function (pt) { return ({
940
- anchor: hrznVrtcToPoint(pt.Anch),
941
- forward: hrznVrtcToPoint(pt['Fwd ']),
942
- backward: hrznVrtcToPoint(pt['Bwd ']),
943
- smooth: pt.Smoo,
912
+ function parseFilterFXItem(f) {
913
+ var base = {
914
+ name: f['Nm '],
915
+ opacity: (0, descriptor_1.parsePercent)(f.blendOptions.Opct),
916
+ blendMode: descriptor_1.BlnM.decode(f.blendOptions['Md ']),
917
+ enabled: f.enab,
918
+ hasOptions: f.hasoptions,
919
+ foregroundColor: (0, descriptor_1.parseColor)(f.FrgC),
920
+ backgroundColor: (0, descriptor_1.parseColor)(f.BckC),
921
+ };
922
+ switch (f.filterID) {
923
+ case 1098281575: return __assign(__assign({}, base), { type: 'average' });
924
+ case 1114403360: return __assign(__assign({}, base), { type: 'blur' });
925
+ case 1114403405: return __assign(__assign({}, base), { type: 'blur more' });
926
+ case 697: return __assign(__assign({}, base), { type: 'box blur', filter: {
927
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
928
+ } });
929
+ case 1198747202: return __assign(__assign({}, base), { type: 'gaussian blur', filter: {
930
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
931
+ } });
932
+ case 1299476034: return __assign(__assign({}, base), { type: 'motion blur', filter: {
933
+ angle: f.Fltr.Angl,
934
+ distance: (0, descriptor_1.parseUnits)(f.Fltr.Dstn),
935
+ } });
936
+ case 1382313026: return __assign(__assign({}, base), { type: 'radial blur', filter: {
937
+ amount: f.Fltr.Amnt,
938
+ method: descriptor_1.BlrM.decode(f.Fltr.BlrM),
939
+ quality: descriptor_1.BlrQ.decode(f.Fltr.BlrQ),
940
+ } });
941
+ case 702: return __assign(__assign({}, base), { type: 'shape blur', filter: {
942
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
943
+ customShape: { name: f.Fltr.customShape['Nm '], id: f.Fltr.customShape.Idnt },
944
+ } });
945
+ case 1399681602: return __assign(__assign({}, base), { type: 'smart blur', filter: {
946
+ radius: f.Fltr['Rds '],
947
+ threshold: f.Fltr.Thsh,
948
+ quality: descriptor_1.SmBQ.decode(f.Fltr.SmBQ),
949
+ mode: descriptor_1.SmBM.decode(f.Fltr.SmBM),
950
+ } });
951
+ case 701: return __assign(__assign({}, base), { type: 'surface blur', filter: {
952
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
953
+ threshold: f.Fltr.Thsh,
954
+ } });
955
+ case 1148416108: return __assign(__assign({}, base), { type: 'displace', filter: {
956
+ horizontalScale: f.Fltr.HrzS,
957
+ verticalScale: f.Fltr.VrtS,
958
+ displacementMap: descriptor_1.DspM.decode(f.Fltr.DspM),
959
+ undefinedAreas: descriptor_1.UndA.decode(f.Fltr.UndA),
960
+ displacementFile: {
961
+ signature: f.Fltr.DspF.sig,
962
+ path: f.Fltr.DspF.path, // TODO: this is decoded incorrectly ???
963
+ },
964
+ } });
965
+ case 1349411688: return __assign(__assign({}, base), { type: 'pinch', filter: {
966
+ amount: f.Fltr.Amnt,
967
+ } });
968
+ case 1349284384: return __assign(__assign({}, base), { type: 'polar coordinates', filter: {
969
+ conversion: descriptor_1.Cnvr.decode(f.Fltr.Cnvr),
970
+ } });
971
+ case 1383099493: return __assign(__assign({}, base), { type: 'ripple', filter: {
972
+ amount: f.Fltr.Amnt,
973
+ size: descriptor_1.RplS.decode(f.Fltr.RplS),
974
+ } });
975
+ case 1399353888: return __assign(__assign({}, base), { type: 'shear', filter: {
976
+ shearPoints: f.Fltr.ShrP.map(function (p) { return ({ x: p.Hrzn, y: p.Vrtc }); }),
977
+ shearStart: f.Fltr.ShrS,
978
+ shearEnd: f.Fltr.ShrE,
979
+ undefinedAreas: descriptor_1.UndA.decode(f.Fltr.UndA),
980
+ } });
981
+ case 1399875698: return __assign(__assign({}, base), { type: 'spherize', filter: {
982
+ amount: f.Fltr.Amnt,
983
+ mode: descriptor_1.SphM.decode(f.Fltr.SphM),
984
+ } });
985
+ case 1417114220: return __assign(__assign({}, base), { type: 'twirl', filter: {
986
+ angle: f.Fltr.Angl,
987
+ } });
988
+ case 1466005093: return __assign(__assign({}, base), { type: 'wave', filter: {
989
+ numberOfGenerators: f.Fltr.NmbG,
990
+ type: descriptor_1.Wvtp.decode(f.Fltr.Wvtp),
991
+ wavelength: { min: f.Fltr.WLMn, max: f.Fltr.WLMx },
992
+ amplitude: { min: f.Fltr.AmMn, max: f.Fltr.AmMx },
993
+ scale: { x: f.Fltr.SclH, y: f.Fltr.SclV },
994
+ randomSeed: f.Fltr.RndS,
995
+ undefinedAreas: descriptor_1.UndA.decode(f.Fltr.UndA),
996
+ } });
997
+ case 1516722791: return __assign(__assign({}, base), { type: 'zigzag', filter: {
998
+ amount: f.Fltr.Amnt,
999
+ ridges: f.Fltr.NmbR,
1000
+ style: descriptor_1.ZZTy.decode(f.Fltr.ZZTy),
1001
+ } });
1002
+ case 1097092723: return __assign(__assign({}, base), { type: 'add noise', filter: {
1003
+ amount: (0, descriptor_1.parsePercent)(f.Fltr.Nose),
1004
+ distribution: descriptor_1.Dstr.decode(f.Fltr.Dstr),
1005
+ monochromatic: f.Fltr.Mnch,
1006
+ randomSeed: f.Fltr.FlRs,
1007
+ } });
1008
+ case 1148416099: return __assign(__assign({}, base), { type: 'despeckle' });
1009
+ case 1148417107: return __assign(__assign({}, base), { type: 'dust and scratches', filter: {
1010
+ radius: f.Fltr['Rds '],
1011
+ threshold: f.Fltr.Thsh,
1012
+ } });
1013
+ case 1298427424: return __assign(__assign({}, base), { type: 'median', filter: {
1014
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1015
+ } });
1016
+ case 633: return __assign(__assign({}, base), { type: 'reduce noise', filter: {
1017
+ preset: f.Fltr.preset,
1018
+ removeJpegArtifact: f.Fltr.removeJPEGArtifact,
1019
+ reduceColorNoise: (0, descriptor_1.parsePercent)(f.Fltr.ClNs),
1020
+ sharpenDetails: (0, descriptor_1.parsePercent)(f.Fltr.Shrp),
1021
+ channelDenoise: f.Fltr.channelDenoise.map(function (c) { return (__assign({ channels: c.Chnl.map(function (i) { return descriptor_1.Chnl.decode(i); }), amount: c.Amnt }, (c.EdgF ? { preserveDetails: c.EdgF } : {}))); }),
1022
+ } });
1023
+ case 1131180616: return __assign(__assign({}, base), { type: 'color halftone', filter: {
1024
+ radius: f.Fltr['Rds '],
1025
+ angle1: f.Fltr.Ang1,
1026
+ angle2: f.Fltr.Ang2,
1027
+ angle3: f.Fltr.Ang3,
1028
+ angle4: f.Fltr.Ang4,
1029
+ } });
1030
+ case 1131574132: return __assign(__assign({}, base), { type: 'crystallize', filter: {
1031
+ cellSize: f.Fltr.ClSz,
1032
+ randomSeed: f.Fltr.FlRs,
1033
+ } });
1034
+ case 1180922912: return __assign(__assign({}, base), { type: 'facet' });
1035
+ case 1181902701: return __assign(__assign({}, base), { type: 'fragment' });
1036
+ case 1299870830: return __assign(__assign({}, base), { type: 'mezzotint', filter: {
1037
+ type: descriptor_1.MztT.decode(f.Fltr.MztT),
1038
+ randomSeed: f.Fltr.FlRs,
1039
+ } });
1040
+ case 1299407648: return __assign(__assign({}, base), { type: 'mosaic', filter: {
1041
+ cellSize: (0, descriptor_1.parseUnits)(f.Fltr.ClSz),
1042
+ } });
1043
+ case 1349416044: return __assign(__assign({}, base), { type: 'pointillize', filter: {
1044
+ cellSize: f.Fltr.ClSz,
1045
+ randomSeed: f.Fltr.FlRs,
1046
+ } });
1047
+ case 1131177075: return __assign(__assign({}, base), { type: 'clouds', filter: {
1048
+ randomSeed: f.Fltr.FlRs,
1049
+ } });
1050
+ case 1147564611: return __assign(__assign({}, base), { type: 'difference clouds', filter: {
1051
+ randomSeed: f.Fltr.FlRs,
1052
+ } });
1053
+ case 1180856947: return __assign(__assign({}, base), { type: 'fibers', filter: {
1054
+ variance: f.Fltr.Vrnc,
1055
+ strength: f.Fltr.Strg,
1056
+ randomSeed: f.Fltr.RndS,
1057
+ } });
1058
+ case 1282306886: return __assign(__assign({}, base), { type: 'lens flare', filter: {
1059
+ brightness: f.Fltr.Brgh,
1060
+ position: { x: f.Fltr.FlrC.Hrzn, y: f.Fltr.FlrC.Vrtc },
1061
+ lensType: descriptor_1.Lns.decode(f.Fltr['Lns ']),
1062
+ } });
1063
+ case 1399353968: return __assign(__assign({}, base), { type: 'sharpen' });
1064
+ case 1399353925: return __assign(__assign({}, base), { type: 'sharpen edges' });
1065
+ case 1399353933: return __assign(__assign({}, base), { type: 'sharpen more' });
1066
+ case 698: return __assign(__assign({}, base), { type: 'smart sharpen', filter: {
1067
+ amount: (0, descriptor_1.parsePercent)(f.Fltr.Amnt),
1068
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1069
+ threshold: f.Fltr.Thsh,
1070
+ angle: f.Fltr.Angl,
1071
+ moreAccurate: f.Fltr.moreAccurate,
1072
+ blur: descriptor_1.blurType.decode(f.Fltr.blur),
1073
+ preset: f.Fltr.preset,
1074
+ shadow: {
1075
+ fadeAmount: (0, descriptor_1.parsePercent)(f.Fltr.sdwM.Amnt),
1076
+ tonalWidth: (0, descriptor_1.parsePercent)(f.Fltr.sdwM.Wdth),
1077
+ radius: f.Fltr.sdwM['Rds '],
1078
+ },
1079
+ highlight: {
1080
+ fadeAmount: (0, descriptor_1.parsePercent)(f.Fltr.hglM.Amnt),
1081
+ tonalWidth: (0, descriptor_1.parsePercent)(f.Fltr.hglM.Wdth),
1082
+ radius: f.Fltr.hglM['Rds '],
1083
+ },
1084
+ } });
1085
+ case 1433301837: return __assign(__assign({}, base), { type: 'unsharp mask', filter: {
1086
+ amount: (0, descriptor_1.parsePercent)(f.Fltr.Amnt),
1087
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1088
+ threshold: f.Fltr.Thsh,
1089
+ } });
1090
+ case 1147564832: return __assign(__assign({}, base), { type: 'diffuse', filter: {
1091
+ mode: descriptor_1.DfsM.decode(f.Fltr['Md ']),
1092
+ randomSeed: f.Fltr.FlRs,
1093
+ } });
1094
+ case 1164796531: return __assign(__assign({}, base), { type: 'emboss', filter: {
1095
+ angle: f.Fltr.Angl,
1096
+ height: f.Fltr.Hght,
1097
+ amount: f.Fltr.Amnt,
1098
+ } });
1099
+ case 1165522034: return __assign(__assign({}, base), { type: 'extrude', filter: {
1100
+ type: descriptor_1.ExtT.decode(f.Fltr.ExtT),
1101
+ size: f.Fltr.ExtS,
1102
+ depth: f.Fltr.ExtD,
1103
+ depthMode: descriptor_1.ExtR.decode(f.Fltr.ExtR),
1104
+ randomSeed: f.Fltr.FlRs,
1105
+ solidFrontFaces: f.Fltr.ExtF,
1106
+ maskIncompleteBlocks: f.Fltr.ExtM,
1107
+ } });
1108
+ case 1181639749: return __assign(__assign({}, base), { type: 'find edges' });
1109
+ case 1399616122: return __assign(__assign({}, base), { type: 'solarize' });
1110
+ case 1416393504: return __assign(__assign({}, base), { type: 'tiles', filter: {
1111
+ numberOfTiles: f.Fltr.TlNm,
1112
+ maximumOffset: f.Fltr.TlOf,
1113
+ fillEmptyAreaWith: descriptor_1.FlCl.decode(f.Fltr.FlCl),
1114
+ randomSeed: f.Fltr.FlRs,
1115
+ } });
1116
+ case 1416782659: return __assign(__assign({}, base), { type: 'trace contour', filter: {
1117
+ level: f.Fltr['Lvl '],
1118
+ edge: descriptor_1.CntE.decode(f.Fltr['Edg ']),
1119
+ } });
1120
+ case 1466852384: return __assign(__assign({}, base), { type: 'wind', filter: {
1121
+ method: descriptor_1.WndM.decode(f.Fltr.WndM),
1122
+ direction: descriptor_1.Drct.decode(f.Fltr.Drct),
1123
+ } });
1124
+ case 1148089458: return __assign(__assign({}, base), { type: 'de-interlace', filter: {
1125
+ eliminate: descriptor_1.IntE.decode(f.Fltr.IntE),
1126
+ newFieldsBy: descriptor_1.IntC.decode(f.Fltr.IntC),
1127
+ } });
1128
+ case 1314149187: return __assign(__assign({}, base), { type: 'ntsc colors' });
1129
+ case 1131639917: return __assign(__assign({}, base), { type: 'custom', filter: {
1130
+ scale: f.Fltr['Scl '],
1131
+ offset: f.Fltr.Ofst,
1132
+ matrix: f.Fltr.Mtrx,
1133
+ } });
1134
+ case 1214736464: return __assign(__assign({}, base), { type: 'high pass', filter: {
1135
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1136
+ } });
1137
+ case 1299737888: return __assign(__assign({}, base), { type: 'maximum', filter: {
1138
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1139
+ } });
1140
+ case 1299082528: return __assign(__assign({}, base), { type: 'minimum', filter: {
1141
+ radius: (0, descriptor_1.parseUnits)(f.Fltr['Rds ']),
1142
+ } });
1143
+ case 1332114292: return __assign(__assign({}, base), { type: 'offset', filter: {
1144
+ horizontal: f.Fltr.Hrzn,
1145
+ vertical: f.Fltr.Vrtc,
1146
+ undefinedAreas: descriptor_1.FlMd.decode(f.Fltr['Fl ']),
1147
+ } });
1148
+ case 991: return __assign(__assign({}, base), { type: 'puppet', filter: {
1149
+ rigidType: f.Fltr.rigidType,
1150
+ bounds: [
1151
+ { x: f.Fltr.PuX0, y: f.Fltr.PuY0, },
1152
+ { x: f.Fltr.PuX1, y: f.Fltr.PuY1, },
1153
+ { x: f.Fltr.PuX2, y: f.Fltr.PuY2, },
1154
+ { x: f.Fltr.PuX3, y: f.Fltr.PuY3, },
1155
+ ],
1156
+ puppetShapeList: f.Fltr.puppetShapeList.map(function (p) { return ({
1157
+ rigidType: p.rigidType,
1158
+ // TODO: VrsM
1159
+ // TODO: VrsN
1160
+ originalVertexArray: uint8ToPoints(p.originalVertexArray),
1161
+ deformedVertexArray: uint8ToPoints(p.deformedVertexArray),
1162
+ indexArray: Array.from(uint8ToUint32(p.indexArray)),
1163
+ pinOffsets: arrayToPoints(p.pinOffsets),
1164
+ posFinalPins: arrayToPoints(p.posFinalPins),
1165
+ pinVertexIndices: p.pinVertexIndices,
1166
+ selectedPin: p.selectedPin,
1167
+ pinPosition: arrayToPoints(p.PinP),
1168
+ pinRotation: p.PnRt,
1169
+ pinOverlay: p.PnOv,
1170
+ pinDepth: p.PnDp,
1171
+ meshQuality: p.meshQuality,
1172
+ meshExpansion: p.meshExpansion,
1173
+ meshRigidity: p.meshRigidity,
1174
+ imageResolution: p.imageResolution,
1175
+ meshBoundaryPath: {
1176
+ pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
1177
+ shapeOperation: c.shapeOperation.split('.')[1],
1178
+ paths: c.SbpL.map(function (t) { return ({
1179
+ closed: t.Clsp,
1180
+ points: t['Pts '].map(function (pt) { return ({
1181
+ anchor: hrznVrtcToPoint(pt.Anch),
1182
+ forward: hrznVrtcToPoint(pt['Fwd ']),
1183
+ backward: hrznVrtcToPoint(pt['Bwd ']),
1184
+ smooth: pt.Smoo,
1185
+ }); }),
944
1186
  }); }),
945
1187
  }); }),
946
- }); }),
947
- },
948
- }); }),
949
- };
950
- }
951
- else {
952
- return {};
1188
+ },
1189
+ }); }),
1190
+ } });
1191
+ case 1348620396: {
1192
+ var parameters = [];
1193
+ var Flrt = f.Fltr;
1194
+ for (var i = 0; i < fromAtoZ.length; i++) {
1195
+ if (!Flrt["PN".concat(fromAtoZ[i], "a")])
1196
+ break;
1197
+ for (var j = 0; j < fromAtoZ.length; j++) {
1198
+ if (!Flrt["PN".concat(fromAtoZ[i]).concat(fromAtoZ[j])])
1199
+ break;
1200
+ parameters.push({
1201
+ name: Flrt["PN".concat(fromAtoZ[i]).concat(fromAtoZ[j])],
1202
+ value: Flrt["PF".concat(fromAtoZ[i]).concat(fromAtoZ[j])]
1203
+ });
1204
+ }
1205
+ }
1206
+ return __assign(__assign({}, base), { type: 'oil paint plugin', filter: {
1207
+ name: f.Fltr.KnNm,
1208
+ gpu: f.Fltr.GpuY,
1209
+ lighting: f.Fltr.LIWy,
1210
+ parameters: parameters,
1211
+ } });
1212
+ }
1213
+ // case 2089: return {
1214
+ // ...base,
1215
+ // type: 'adaptive wide angle',
1216
+ // params: {
1217
+ // correction: prjM.decode(f.Fltr.prjM),
1218
+ // focalLength: f.Fltr.focL,
1219
+ // cropFactor: f.Fltr.CrpF,
1220
+ // imageScale: f.Fltr.imgS,
1221
+ // imageX: f.Fltr.imgX,
1222
+ // imageY: f.Fltr.imgY,
1223
+ // },
1224
+ // };
1225
+ case 1215521360: return __assign(__assign({}, base), { type: 'hsb/hsl', filter: {
1226
+ inputMode: descriptor_1.ClrS.decode(f.Fltr.Inpt),
1227
+ rowOrder: descriptor_1.ClrS.decode(f.Fltr.Otpt),
1228
+ } });
1229
+ case 1122: return __assign(__assign({}, base), { type: 'oil paint', filter: {
1230
+ lightingOn: f.Fltr.lightingOn,
1231
+ stylization: f.Fltr.stylization,
1232
+ cleanliness: f.Fltr.cleanliness,
1233
+ brushScale: f.Fltr.brushScale,
1234
+ microBrush: f.Fltr.microBrush,
1235
+ lightDirection: f.Fltr.LghD,
1236
+ specularity: f.Fltr.specularity,
1237
+ } });
1238
+ case 1282492025: {
1239
+ return __assign(__assign({}, base), { type: 'liquify', filter: {
1240
+ liquifyMesh: f.Fltr.LqMe,
1241
+ } });
1242
+ }
1243
+ default:
1244
+ throw new Error("Unknown filterID: ".concat(f.filterID));
953
1245
  }
954
1246
  }
955
1247
  function parseFilterFX(desc) {
@@ -959,96 +1251,446 @@ function parseFilterFX(desc) {
959
1251
  maskEnabled: desc.filterMaskEnable,
960
1252
  maskLinked: desc.filterMaskLinked,
961
1253
  maskExtendWithWhite: desc.filterMaskExtendWithWhite,
962
- list: desc.filterFXList.map(function (f) { return ({
963
- id: f.filterID,
964
- name: f['Nm '],
965
- opacity: (0, descriptor_1.parsePercent)(f.blendOptions.Opct),
966
- blendMode: descriptor_1.BlnM.decode(f.blendOptions['Md ']),
967
- enabled: f.enab,
968
- hasOptions: f.hasoptions,
969
- foregroundColor: (0, descriptor_1.parseColor)(f.FrgC),
970
- backgroundColor: (0, descriptor_1.parseColor)(f.BckC),
971
- filter: parseFilterFXFilter(f.Fltr),
972
- }); }),
1254
+ list: desc.filterFXList.map(parseFilterFXItem),
973
1255
  };
974
1256
  }
975
- function serializeFltr(filter) {
976
- if ('puppetShapeList' in filter) {
977
- return {
978
- 'null': ['Ordn.Trgt'],
979
- rigidType: filter.rigidType,
980
- puppetShapeList: filter.puppetShapeList.map(function (p) { return ({
981
- rigidType: p.rigidType,
982
- VrsM: 1,
983
- VrsN: 0,
984
- originalVertexArray: toUint8(new Float32Array(pointsToArray(p.originalVertexArray))),
985
- deformedVertexArray: toUint8(new Float32Array(pointsToArray(p.deformedVertexArray))),
986
- indexArray: toUint8(new Uint32Array(p.indexArray)),
987
- pinOffsets: pointsToArray(p.pinOffsets),
988
- posFinalPins: pointsToArray(p.posFinalPins),
989
- selectedPin: p.selectedPin,
990
- pinVertexIndices: p.pinVertexIndices,
991
- PinP: pointsToArray(p.pinPosition),
992
- PnRt: p.pinRotation,
993
- PnOv: p.pinOverlay,
994
- PnDp: p.pinDepth,
995
- meshQuality: p.meshQuality,
996
- meshExpansion: p.meshExpansion,
997
- meshRigidity: p.meshRigidity,
998
- imageResolution: p.imageResolution,
999
- meshBoundaryPath: {
1000
- pathComponents: (p.meshBoundaryPath.pathComponents || []).map(function (c) { return ({
1001
- shapeOperation: "shapeOperation.".concat(c.shapeOperation),
1002
- SbpL: (c.paths || []).map(function (path) { return ({
1003
- Clsp: path.closed,
1004
- 'Pts ': (path.points || []).map(function (pt) { return ({
1005
- Anch: pointToHrznVrtc(pt.anchor),
1006
- 'Fwd ': pointToHrznVrtc(pt.forward),
1007
- 'Bwd ': pointToHrznVrtc(pt.backward),
1008
- Smoo: pt.smooth,
1257
+ function uvRadius(t) {
1258
+ return (0, descriptor_1.unitsValue)(t.radius, 'radius');
1259
+ }
1260
+ function serializeFilterFXItem(f) {
1261
+ var base = {
1262
+ _name: '',
1263
+ _classID: 'filterFX',
1264
+ 'Nm ': f.name,
1265
+ blendOptions: {
1266
+ _name: '',
1267
+ _classID: 'blendOptions',
1268
+ Opct: (0, descriptor_1.unitsPercentF)(f.opacity),
1269
+ 'Md ': descriptor_1.BlnM.encode(f.blendMode),
1270
+ },
1271
+ enab: f.enabled,
1272
+ hasoptions: f.hasOptions,
1273
+ FrgC: (0, descriptor_1.serializeColor)(f.foregroundColor),
1274
+ BckC: (0, descriptor_1.serializeColor)(f.backgroundColor),
1275
+ };
1276
+ switch (f.type) {
1277
+ case 'average': return __assign(__assign({}, base), { filterID: 1098281575 });
1278
+ case 'blur': return __assign(__assign({}, base), { filterID: 1114403360 });
1279
+ case 'blur more': return __assign(__assign({}, base), { filterID: 1114403405 });
1280
+ case 'box blur': return __assign(__assign({}, base), { Fltr: {
1281
+ _name: 'Box Blur',
1282
+ _classID: 'boxblur',
1283
+ 'Rds ': uvRadius(f.filter),
1284
+ }, filterID: 697 });
1285
+ case 'gaussian blur': return __assign(__assign({}, base), { Fltr: {
1286
+ _name: 'Gaussian Blur',
1287
+ _classID: 'GsnB',
1288
+ 'Rds ': uvRadius(f.filter),
1289
+ }, filterID: 1198747202 });
1290
+ case 'motion blur': return __assign(__assign({}, base), { Fltr: {
1291
+ _name: 'Motion Blur',
1292
+ _classID: 'MtnB',
1293
+ Angl: f.filter.angle,
1294
+ Dstn: (0, descriptor_1.unitsValue)(f.filter.distance, 'distance'),
1295
+ }, filterID: 1299476034 });
1296
+ case 'radial blur': return __assign(__assign({}, base), { Fltr: {
1297
+ _name: 'Radial Blur',
1298
+ _classID: 'RdlB',
1299
+ Amnt: f.filter.amount,
1300
+ BlrM: descriptor_1.BlrM.encode(f.filter.method),
1301
+ BlrQ: descriptor_1.BlrQ.encode(f.filter.quality),
1302
+ }, filterID: 1382313026 });
1303
+ case 'shape blur': return __assign(__assign({}, base), { Fltr: {
1304
+ _name: 'Shape Blur',
1305
+ _classID: 'shapeBlur',
1306
+ 'Rds ': uvRadius(f.filter),
1307
+ customShape: {
1308
+ _name: '',
1309
+ _classID: 'customShape',
1310
+ 'Nm ': f.filter.customShape.name,
1311
+ Idnt: f.filter.customShape.id,
1312
+ }
1313
+ }, filterID: 702 });
1314
+ case 'smart blur': return __assign(__assign({}, base), { Fltr: {
1315
+ _name: 'Smart Blur',
1316
+ _classID: 'SmrB',
1317
+ 'Rds ': f.filter.radius,
1318
+ Thsh: f.filter.threshold,
1319
+ SmBQ: descriptor_1.SmBQ.encode(f.filter.quality),
1320
+ SmBM: descriptor_1.SmBM.encode(f.filter.mode),
1321
+ }, filterID: 1399681602 });
1322
+ case 'surface blur': return __assign(__assign({}, base), { Fltr: {
1323
+ _name: 'Surface Blur',
1324
+ _classID: 'surfaceBlur',
1325
+ 'Rds ': uvRadius(f.filter),
1326
+ Thsh: f.filter.threshold,
1327
+ }, filterID: 701 });
1328
+ case 'displace': return __assign(__assign({}, base), { Fltr: {
1329
+ _name: 'Displace',
1330
+ _classID: 'Dspl',
1331
+ HrzS: f.filter.horizontalScale,
1332
+ VrtS: f.filter.verticalScale,
1333
+ DspM: descriptor_1.DspM.encode(f.filter.displacementMap),
1334
+ UndA: descriptor_1.UndA.encode(f.filter.undefinedAreas),
1335
+ DspF: {
1336
+ sig: f.filter.displacementFile.signature,
1337
+ path: f.filter.displacementFile.path,
1338
+ },
1339
+ }, filterID: 1148416108 });
1340
+ case 'pinch': return __assign(__assign({}, base), { Fltr: {
1341
+ _name: 'Pinch',
1342
+ _classID: 'Pnch',
1343
+ Amnt: f.filter.amount,
1344
+ }, filterID: 1349411688 });
1345
+ case 'polar coordinates': return __assign(__assign({}, base), { Fltr: {
1346
+ _name: 'Polar Coordinates',
1347
+ _classID: 'Plr ',
1348
+ Cnvr: descriptor_1.Cnvr.encode(f.filter.conversion),
1349
+ }, filterID: 1349284384 });
1350
+ case 'ripple': return __assign(__assign({}, base), { Fltr: {
1351
+ _name: 'Ripple',
1352
+ _classID: 'Rple',
1353
+ Amnt: f.filter.amount,
1354
+ RplS: descriptor_1.RplS.encode(f.filter.size),
1355
+ }, filterID: 1383099493 });
1356
+ case 'shear': return __assign(__assign({}, base), { Fltr: {
1357
+ _name: 'Shear',
1358
+ _classID: 'Shr ',
1359
+ ShrP: f.filter.shearPoints.map(function (p) { return ({ _name: '', _classID: 'Pnt ', Hrzn: p.x, Vrtc: p.y }); }),
1360
+ UndA: descriptor_1.UndA.encode(f.filter.undefinedAreas),
1361
+ ShrS: f.filter.shearStart,
1362
+ ShrE: f.filter.shearEnd,
1363
+ }, filterID: 1399353888 });
1364
+ case 'spherize': return __assign(__assign({}, base), { Fltr: {
1365
+ _name: 'Spherize',
1366
+ _classID: 'Sphr',
1367
+ Amnt: f.filter.amount,
1368
+ SphM: descriptor_1.SphM.encode(f.filter.mode),
1369
+ }, filterID: 1399875698 });
1370
+ case 'twirl': return __assign(__assign({}, base), { Fltr: {
1371
+ _name: 'Twirl',
1372
+ _classID: 'Twrl',
1373
+ Angl: f.filter.angle,
1374
+ }, filterID: 1417114220 });
1375
+ case 'wave': return __assign(__assign({}, base), { Fltr: {
1376
+ _name: 'Wave',
1377
+ _classID: 'Wave',
1378
+ Wvtp: descriptor_1.Wvtp.encode(f.filter.type),
1379
+ NmbG: f.filter.numberOfGenerators,
1380
+ WLMn: f.filter.wavelength.min,
1381
+ WLMx: f.filter.wavelength.max,
1382
+ AmMn: f.filter.amplitude.min,
1383
+ AmMx: f.filter.amplitude.max,
1384
+ SclH: f.filter.scale.x,
1385
+ SclV: f.filter.scale.y,
1386
+ UndA: descriptor_1.UndA.encode(f.filter.undefinedAreas),
1387
+ RndS: f.filter.randomSeed,
1388
+ }, filterID: 1466005093 });
1389
+ case 'zigzag': return __assign(__assign({}, base), { Fltr: {
1390
+ _name: 'ZigZag',
1391
+ _classID: 'ZgZg',
1392
+ Amnt: f.filter.amount,
1393
+ NmbR: f.filter.ridges,
1394
+ ZZTy: descriptor_1.ZZTy.encode(f.filter.style),
1395
+ }, filterID: 1516722791 });
1396
+ case 'add noise': return __assign(__assign({}, base), { Fltr: {
1397
+ _name: 'Add Noise',
1398
+ _classID: 'AdNs',
1399
+ Dstr: descriptor_1.Dstr.encode(f.filter.distribution),
1400
+ Nose: (0, descriptor_1.unitsPercentF)(f.filter.amount),
1401
+ Mnch: f.filter.monochromatic,
1402
+ FlRs: f.filter.randomSeed,
1403
+ }, filterID: 1097092723 });
1404
+ case 'despeckle': return __assign(__assign({}, base), { filterID: 1148416099 });
1405
+ case 'dust and scratches': return __assign(__assign({}, base), { Fltr: {
1406
+ _name: 'Dust & Scratches',
1407
+ _classID: 'DstS',
1408
+ 'Rds ': f.filter.radius,
1409
+ Thsh: f.filter.threshold,
1410
+ }, filterID: 1148417107 });
1411
+ case 'median': return __assign(__assign({}, base), { Fltr: {
1412
+ _name: 'Median',
1413
+ _classID: 'Mdn ',
1414
+ 'Rds ': uvRadius(f.filter),
1415
+ }, filterID: 1298427424 });
1416
+ case 'reduce noise': return __assign(__assign({}, base), { Fltr: {
1417
+ _name: 'Reduce Noise',
1418
+ _classID: 'denoise',
1419
+ ClNs: (0, descriptor_1.unitsPercentF)(f.filter.reduceColorNoise),
1420
+ Shrp: (0, descriptor_1.unitsPercentF)(f.filter.sharpenDetails),
1421
+ removeJPEGArtifact: f.filter.removeJpegArtifact,
1422
+ channelDenoise: f.filter.channelDenoise.map(function (c) { return (__assign({ _name: '', _classID: 'channelDenoiseParams', Chnl: c.channels.map(function (i) { return descriptor_1.Chnl.encode(i); }), Amnt: c.amount }, (c.preserveDetails ? { EdgF: c.preserveDetails } : {}))); }),
1423
+ preset: f.filter.preset,
1424
+ }, filterID: 633 });
1425
+ case 'color halftone': return __assign(__assign({}, base), { Fltr: {
1426
+ _name: 'Color Halftone',
1427
+ _classID: 'ClrH',
1428
+ 'Rds ': f.filter.radius,
1429
+ Ang1: f.filter.angle1,
1430
+ Ang2: f.filter.angle2,
1431
+ Ang3: f.filter.angle3,
1432
+ Ang4: f.filter.angle4,
1433
+ }, filterID: 1131180616 });
1434
+ case 'crystallize': return __assign(__assign({}, base), { Fltr: {
1435
+ _name: 'Crystallize',
1436
+ _classID: 'Crst',
1437
+ ClSz: f.filter.cellSize,
1438
+ FlRs: f.filter.randomSeed,
1439
+ }, filterID: 1131574132 });
1440
+ case 'facet': return __assign(__assign({}, base), { filterID: 1180922912 });
1441
+ case 'fragment': return __assign(__assign({}, base), { filterID: 1181902701 });
1442
+ case 'mezzotint': return __assign(__assign({}, base), { Fltr: {
1443
+ _name: 'Mezzotint',
1444
+ _classID: 'Mztn',
1445
+ MztT: descriptor_1.MztT.encode(f.filter.type),
1446
+ FlRs: f.filter.randomSeed,
1447
+ }, filterID: 1299870830 });
1448
+ case 'mosaic': return __assign(__assign({}, base), { Fltr: {
1449
+ _name: 'Mosaic',
1450
+ _classID: 'Msc ',
1451
+ ClSz: (0, descriptor_1.unitsValue)(f.filter.cellSize, 'cellSize'),
1452
+ }, filterID: 1299407648 });
1453
+ case 'pointillize': return __assign(__assign({}, base), { Fltr: {
1454
+ _name: 'Pointillize',
1455
+ _classID: 'Pntl',
1456
+ ClSz: f.filter.cellSize,
1457
+ FlRs: f.filter.randomSeed,
1458
+ }, filterID: 1349416044 });
1459
+ case 'clouds': return __assign(__assign({}, base), { Fltr: {
1460
+ _name: 'Clouds',
1461
+ _classID: 'Clds',
1462
+ FlRs: f.filter.randomSeed,
1463
+ }, filterID: 1131177075 });
1464
+ case 'difference clouds': return __assign(__assign({}, base), { Fltr: {
1465
+ _name: 'Difference Clouds',
1466
+ _classID: 'DfrC',
1467
+ FlRs: f.filter.randomSeed,
1468
+ }, filterID: 1147564611 });
1469
+ case 'fibers': return __assign(__assign({}, base), { Fltr: {
1470
+ _name: 'Fibers',
1471
+ _classID: 'Fbrs',
1472
+ Vrnc: f.filter.variance,
1473
+ Strg: f.filter.strength,
1474
+ RndS: f.filter.randomSeed,
1475
+ }, filterID: 1180856947 });
1476
+ case 'lens flare': return __assign(__assign({}, base), { Fltr: {
1477
+ _name: 'Lens Flare',
1478
+ _classID: 'LnsF',
1479
+ Brgh: f.filter.brightness,
1480
+ FlrC: {
1481
+ _name: '',
1482
+ _classID: 'Pnt ',
1483
+ Hrzn: f.filter.position.x,
1484
+ Vrtc: f.filter.position.y,
1485
+ },
1486
+ 'Lns ': descriptor_1.Lns.encode(f.filter.lensType),
1487
+ }, filterID: 1282306886 });
1488
+ case 'sharpen': return __assign(__assign({}, base), { filterID: 1399353968 });
1489
+ case 'sharpen edges': return __assign(__assign({}, base), { filterID: 1399353925 });
1490
+ case 'sharpen more': return __assign(__assign({}, base), { filterID: 1399353933 });
1491
+ case 'smart sharpen': return __assign(__assign({}, base), { Fltr: {
1492
+ _name: 'Smart Sharpen',
1493
+ _classID: 'smartSharpen',
1494
+ Amnt: (0, descriptor_1.unitsPercentF)(f.filter.amount),
1495
+ 'Rds ': uvRadius(f.filter),
1496
+ Thsh: f.filter.threshold,
1497
+ Angl: f.filter.angle,
1498
+ moreAccurate: f.filter.moreAccurate,
1499
+ blur: descriptor_1.blurType.encode(f.filter.blur),
1500
+ preset: f.filter.preset,
1501
+ sdwM: {
1502
+ _name: 'Parameters',
1503
+ _classID: 'adaptCorrectTones',
1504
+ Amnt: (0, descriptor_1.unitsPercentF)(f.filter.shadow.fadeAmount),
1505
+ Wdth: (0, descriptor_1.unitsPercentF)(f.filter.shadow.tonalWidth),
1506
+ 'Rds ': f.filter.shadow.radius,
1507
+ },
1508
+ hglM: {
1509
+ _name: 'Parameters',
1510
+ _classID: 'adaptCorrectTones',
1511
+ Amnt: (0, descriptor_1.unitsPercentF)(f.filter.highlight.fadeAmount),
1512
+ Wdth: (0, descriptor_1.unitsPercentF)(f.filter.highlight.tonalWidth),
1513
+ 'Rds ': f.filter.highlight.radius,
1514
+ },
1515
+ }, filterID: 698 });
1516
+ case 'unsharp mask': return __assign(__assign({}, base), { Fltr: {
1517
+ _name: 'Unsharp Mask',
1518
+ _classID: 'UnsM',
1519
+ Amnt: (0, descriptor_1.unitsPercentF)(f.filter.amount),
1520
+ 'Rds ': uvRadius(f.filter),
1521
+ Thsh: f.filter.threshold,
1522
+ }, filterID: 1433301837 });
1523
+ case 'diffuse': return __assign(__assign({}, base), { Fltr: {
1524
+ _name: 'Diffuse',
1525
+ _classID: 'Dfs ',
1526
+ 'Md ': descriptor_1.DfsM.encode(f.filter.mode),
1527
+ FlRs: f.filter.randomSeed,
1528
+ }, filterID: 1147564832 });
1529
+ case 'emboss': return __assign(__assign({}, base), { Fltr: {
1530
+ _name: 'Emboss',
1531
+ _classID: 'Embs',
1532
+ Angl: f.filter.angle,
1533
+ Hght: f.filter.height,
1534
+ Amnt: f.filter.amount,
1535
+ }, filterID: 1164796531 });
1536
+ case 'extrude': return __assign(__assign({}, base), { Fltr: {
1537
+ _name: 'Extrude',
1538
+ _classID: 'Extr',
1539
+ ExtS: f.filter.size,
1540
+ ExtD: f.filter.depth,
1541
+ ExtF: f.filter.solidFrontFaces,
1542
+ ExtM: f.filter.maskIncompleteBlocks,
1543
+ ExtT: descriptor_1.ExtT.encode(f.filter.type),
1544
+ ExtR: descriptor_1.ExtR.encode(f.filter.depthMode),
1545
+ FlRs: f.filter.randomSeed,
1546
+ }, filterID: 1165522034 });
1547
+ case 'find edges': return __assign(__assign({}, base), { filterID: 1181639749 });
1548
+ case 'solarize': return __assign(__assign({}, base), { filterID: 1399616122 });
1549
+ case 'tiles': return __assign(__assign({}, base), { Fltr: {
1550
+ _name: 'Tiles',
1551
+ _classID: 'Tls ',
1552
+ TlNm: f.filter.numberOfTiles,
1553
+ TlOf: f.filter.maximumOffset,
1554
+ FlCl: descriptor_1.FlCl.encode(f.filter.fillEmptyAreaWith),
1555
+ FlRs: f.filter.randomSeed,
1556
+ }, filterID: 1416393504 });
1557
+ case 'trace contour': return __assign(__assign({}, base), { Fltr: {
1558
+ _name: 'Trace Contour',
1559
+ _classID: 'TrcC',
1560
+ 'Lvl ': f.filter.level,
1561
+ 'Edg ': descriptor_1.CntE.encode(f.filter.edge),
1562
+ }, filterID: 1416782659 });
1563
+ case 'wind': return __assign(__assign({}, base), { Fltr: {
1564
+ _name: 'Wind',
1565
+ _classID: 'Wnd ',
1566
+ WndM: descriptor_1.WndM.encode(f.filter.method),
1567
+ Drct: descriptor_1.Drct.encode(f.filter.direction),
1568
+ }, filterID: 1466852384 });
1569
+ case 'de-interlace': return __assign(__assign({}, base), { Fltr: {
1570
+ _name: 'De-Interlace',
1571
+ _classID: 'Dntr',
1572
+ IntE: descriptor_1.IntE.encode(f.filter.eliminate),
1573
+ IntC: descriptor_1.IntC.encode(f.filter.newFieldsBy),
1574
+ }, filterID: 1148089458 });
1575
+ case 'ntsc colors': return __assign(__assign({}, base), { filterID: 1314149187 });
1576
+ case 'custom': return __assign(__assign({}, base), { Fltr: {
1577
+ _name: 'Custom',
1578
+ _classID: 'Cstm',
1579
+ 'Scl ': f.filter.scale,
1580
+ Ofst: f.filter.offset,
1581
+ Mtrx: f.filter.matrix,
1582
+ }, filterID: 1131639917 });
1583
+ case 'high pass': return __assign(__assign({}, base), { Fltr: {
1584
+ _name: 'High Pass',
1585
+ _classID: 'HghP',
1586
+ 'Rds ': uvRadius(f.filter),
1587
+ }, filterID: 1214736464 });
1588
+ case 'maximum': return __assign(__assign({}, base), { Fltr: {
1589
+ _name: 'Maximum',
1590
+ _classID: 'Mxm ',
1591
+ 'Rds ': uvRadius(f.filter),
1592
+ }, filterID: 1299737888 });
1593
+ case 'minimum': return __assign(__assign({}, base), { Fltr: {
1594
+ _name: 'Minimum',
1595
+ _classID: 'Mnm ',
1596
+ 'Rds ': uvRadius(f.filter),
1597
+ }, filterID: 1299082528 });
1598
+ case 'offset': return __assign(__assign({}, base), { Fltr: {
1599
+ _name: 'Offset',
1600
+ _classID: 'Ofst',
1601
+ Hrzn: f.filter.horizontal,
1602
+ Vrtc: f.filter.vertical,
1603
+ 'Fl ': descriptor_1.FlMd.encode(f.filter.undefinedAreas),
1604
+ }, filterID: 1332114292 });
1605
+ case 'puppet': return __assign(__assign({}, base), { Fltr: {
1606
+ _name: 'Rigid Transform',
1607
+ _classID: 'rigidTransform',
1608
+ 'null': ['Ordn.Trgt'],
1609
+ rigidType: f.filter.rigidType,
1610
+ puppetShapeList: f.filter.puppetShapeList.map(function (p) { return ({
1611
+ _name: '',
1612
+ _classID: 'puppetShape',
1613
+ rigidType: p.rigidType,
1614
+ VrsM: 1,
1615
+ VrsN: 0,
1616
+ originalVertexArray: toUint8(new Float32Array(pointsToArray(p.originalVertexArray))),
1617
+ deformedVertexArray: toUint8(new Float32Array(pointsToArray(p.deformedVertexArray))),
1618
+ indexArray: toUint8(new Uint32Array(p.indexArray)),
1619
+ pinOffsets: pointsToArray(p.pinOffsets),
1620
+ posFinalPins: pointsToArray(p.posFinalPins),
1621
+ pinVertexIndices: p.pinVertexIndices,
1622
+ PinP: pointsToArray(p.pinPosition),
1623
+ PnRt: p.pinRotation,
1624
+ PnOv: p.pinOverlay,
1625
+ PnDp: p.pinDepth,
1626
+ meshQuality: p.meshQuality,
1627
+ meshExpansion: p.meshExpansion,
1628
+ meshRigidity: p.meshRigidity,
1629
+ imageResolution: p.imageResolution,
1630
+ meshBoundaryPath: {
1631
+ _name: '',
1632
+ _classID: 'pathClass',
1633
+ pathComponents: p.meshBoundaryPath.pathComponents.map(function (c) { return ({
1634
+ _name: '',
1635
+ _classID: 'PaCm',
1636
+ shapeOperation: "shapeOperation.".concat(c.shapeOperation),
1637
+ SbpL: c.paths.map(function (path) { return ({
1638
+ _name: '',
1639
+ _classID: 'Sbpl',
1640
+ Clsp: path.closed,
1641
+ 'Pts ': path.points.map(function (pt) { return ({
1642
+ _name: '',
1643
+ _classID: 'Pthp',
1644
+ Anch: pointToHrznVrtc(pt.anchor),
1645
+ 'Fwd ': pointToHrznVrtc(pt.forward),
1646
+ 'Bwd ': pointToHrznVrtc(pt.backward),
1647
+ Smoo: pt.smooth,
1648
+ }); }),
1009
1649
  }); }),
1010
1650
  }); }),
1011
- }); }),
1012
- },
1013
- }); }),
1014
- PuX0: filter.bounds[0].x,
1015
- PuX1: filter.bounds[1].x,
1016
- PuX2: filter.bounds[2].x,
1017
- PuX3: filter.bounds[3].x,
1018
- PuY0: filter.bounds[0].y,
1019
- PuY1: filter.bounds[1].y,
1020
- PuY2: filter.bounds[2].y,
1021
- PuY3: filter.bounds[3].y,
1022
- };
1023
- }
1024
- else {
1025
- return {
1026
- LqMe: new Uint8Array(),
1027
- };
1651
+ },
1652
+ selectedPin: p.selectedPin,
1653
+ }); }),
1654
+ PuX0: f.filter.bounds[0].x,
1655
+ PuX1: f.filter.bounds[1].x,
1656
+ PuX2: f.filter.bounds[2].x,
1657
+ PuX3: f.filter.bounds[3].x,
1658
+ PuY0: f.filter.bounds[0].y,
1659
+ PuY1: f.filter.bounds[1].y,
1660
+ PuY2: f.filter.bounds[2].y,
1661
+ PuY3: f.filter.bounds[3].y,
1662
+ }, filterID: 991 });
1663
+ case 'oil paint plugin': {
1664
+ var params = {};
1665
+ for (var i = 0; i < f.filter.parameters.length; i++) {
1666
+ var _a = f.filter.parameters[i], name_1 = _a.name, value = _a.value;
1667
+ var suffix = "".concat(fromAtoZ[Math.floor(i / fromAtoZ.length)]).concat(fromAtoZ[i % fromAtoZ.length]);
1668
+ params["PN".concat(suffix)] = name_1;
1669
+ params["PT".concat(suffix)] = 0;
1670
+ params["PF".concat(suffix)] = value;
1671
+ }
1672
+ return __assign(__assign({}, base), { Fltr: __assign({ _name: 'Oil Paint Plugin', _classID: 'PbPl', KnNm: f.filter.name, GpuY: f.filter.gpu, LIWy: f.filter.lighting, FPth: '1' }, params), filterID: 1348620396 });
1673
+ }
1674
+ case 'oil paint': return __assign(__assign({}, base), { Fltr: {
1675
+ _name: 'Oil Paint',
1676
+ _classID: 'oilPaint',
1677
+ lightingOn: f.filter.lightingOn,
1678
+ stylization: f.filter.stylization,
1679
+ cleanliness: f.filter.cleanliness,
1680
+ brushScale: f.filter.brushScale,
1681
+ microBrush: f.filter.microBrush,
1682
+ LghD: f.filter.lightDirection,
1683
+ specularity: f.filter.specularity,
1684
+ }, filterID: 1122 });
1685
+ case 'liquify': return __assign(__assign({}, base), { Fltr: {
1686
+ _name: 'Liquify',
1687
+ _classID: 'LqFy',
1688
+ LqMe: f.filter.liquifyMesh,
1689
+ }, filterID: 1282492025 });
1690
+ default: throw new Error("Unknow filter type: ".concat(f.type));
1028
1691
  }
1029
1692
  }
1030
- function serializeFilterFX(filter) {
1031
- return {
1032
- enab: filter.enabled,
1033
- validAtPosition: filter.validAtPosition,
1034
- filterMaskEnable: filter.maskEnabled,
1035
- filterMaskLinked: filter.maskLinked,
1036
- filterMaskExtendWithWhite: filter.maskExtendWithWhite,
1037
- filterFXList: (filter.list || []).map(function (f) { return ({
1038
- 'Nm ': f.name,
1039
- blendOptions: {
1040
- Opct: (0, descriptor_1.unitsPercent)(f.opacity),
1041
- 'Md ': descriptor_1.BlnM.encode(f.blendMode),
1042
- },
1043
- enab: f.enabled,
1044
- hasoptions: f.hasOptions,
1045
- FrgC: (0, descriptor_1.serializeColor)(f.foregroundColor),
1046
- BckC: (0, descriptor_1.serializeColor)(f.backgroundColor),
1047
- Fltr: serializeFltr(f.filter),
1048
- filterID: f.id,
1049
- }); }),
1050
- };
1051
- }
1693
+ // let t: any;
1052
1694
  addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
1053
1695
  if ((0, psdReader_1.readSignature)(reader) !== 'soLD')
1054
1696
  throw new Error("Invalid SoLd type");
@@ -1060,15 +1702,17 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
1060
1702
  // console.log('SoLd.warp', require('util').inspect(desc.warp, false, 99, true));
1061
1703
  // console.log('SoLd.quiltWarp', require('util').inspect(desc.quiltWarp, false, 99, true));
1062
1704
  // desc.filterFX!.filterFXList[0].Fltr.puppetShapeList[0].meshBoundaryPath.pathComponents[0].SbpL[0]['Pts '] = [];
1063
- // console.log('filterFX', require('util').inspect(desc.filterFX, false, 99, true));
1705
+ // console.log('read', require('util').inspect(desc.filterFX, false, 99, true));
1706
+ // console.log('filterFXList[0]', require('util').inspect((desc as any).filterFX.filterFXList[0], false, 99, true));
1707
+ // t = desc;
1064
1708
  target.placedLayer = {
1065
1709
  id: desc.Idnt,
1066
1710
  placed: desc.placed,
1067
1711
  type: placedLayerTypes[desc.Type],
1068
1712
  pageNumber: desc.PgNm,
1069
1713
  totalPages: desc.totalPages,
1070
- frameStep: desc.frameStep,
1071
- duration: desc.duration,
1714
+ frameStep: (0, descriptor_1.frac)(desc.frameStep),
1715
+ duration: (0, descriptor_1.frac)(desc.duration),
1072
1716
  frameCount: desc.frameCount,
1073
1717
  transform: desc.Trnf,
1074
1718
  width: desc['Sz '].Wdth,
@@ -1083,22 +1727,48 @@ addHandler('SoLd', hasKey('placedLayer'), function (reader, target, left) {
1083
1727
  target.placedLayer.crop = desc.Crop;
1084
1728
  if (desc.comp)
1085
1729
  target.placedLayer.comp = desc.comp;
1086
- if (desc.compInfo)
1087
- target.placedLayer.compInfo = desc.compInfo;
1730
+ if (desc.compInfo) {
1731
+ target.placedLayer.compInfo = {
1732
+ compID: desc.compInfo.compID,
1733
+ originalCompID: desc.compInfo.originalCompID,
1734
+ };
1735
+ }
1088
1736
  if (desc.filterFX)
1089
1737
  target.placedLayer.filter = parseFilterFX(desc.filterFX);
1738
+ // console.log('filter', require('util').inspect(target.placedLayer.filter, false, 99, true));
1090
1739
  (0, psdReader_1.skipBytes)(reader, left()); // HACK
1091
1740
  }, function (writer, target) {
1092
1741
  var _a, _b;
1093
1742
  (0, psdWriter_1.writeSignature)(writer, 'soLD');
1094
1743
  (0, psdWriter_1.writeInt32)(writer, 4); // version
1095
1744
  var placed = target.placedLayer;
1096
- var desc = __assign(__assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform, quiltWarp: {}, warp: encodeWarp(placed.warp || {}), 'Sz ': {
1745
+ var desc = __assign(__assign({ Idnt: placed.id, placed: (_a = placed.placed) !== null && _a !== void 0 ? _a : placed.id, PgNm: placed.pageNumber || 1, totalPages: placed.totalPages || 1 }, (placed.crop ? { Crop: placed.crop } : {})), { frameStep: placed.frameStep || { numerator: 0, denominator: 600 }, duration: placed.duration || { numerator: 0, denominator: 600 }, frameCount: placed.frameCount || 0, Annt: 16, Type: placedLayerTypes.indexOf(placed.type), Trnf: placed.transform, nonAffineTransform: (_b = placed.nonAffineTransform) !== null && _b !== void 0 ? _b : placed.transform,
1746
+ // quiltWarp: {} as any,
1747
+ warp: encodeWarp(placed.warp || {}), 'Sz ': {
1748
+ _name: '',
1749
+ _classID: 'Pnt ',
1097
1750
  Wdth: placed.width || 0,
1098
1751
  Hght: placed.height || 0, // TODO: find size ?
1099
1752
  }, Rslt: placed.resolution ? (0, descriptor_1.unitsValue)(placed.resolution, 'resolution') : { units: 'Density', value: 72 } });
1100
- if (placed.filter)
1101
- desc.filterFX = serializeFilterFX(placed.filter);
1753
+ if (placed.filter) {
1754
+ desc.filterFX = {
1755
+ _name: '',
1756
+ _classID: 'filterFXStyle',
1757
+ enab: placed.filter.enabled,
1758
+ validAtPosition: placed.filter.validAtPosition,
1759
+ filterMaskEnable: placed.filter.maskEnabled,
1760
+ filterMaskLinked: placed.filter.maskLinked,
1761
+ filterMaskExtendWithWhite: placed.filter.maskExtendWithWhite,
1762
+ filterFXList: placed.filter.list.map(function (f) { return serializeFilterFXItem(f); }),
1763
+ };
1764
+ }
1765
+ // console.log('write', require('util').inspect(desc.filterFX, false, 99, true)); ///
1766
+ // if (JSON.stringify(t) !== JSON.stringify(desc)) {
1767
+ // console.log('read', require('util').inspect(t, false, 99, true));
1768
+ // console.log('write', require('util').inspect(desc, false, 99, true));
1769
+ // console.error('DIFFERENT');
1770
+ // // throw new Error('DIFFERENT');
1771
+ // }
1102
1772
  if (placed.warp && isQuiltWarp(placed.warp)) {
1103
1773
  var quiltWarp = encodeWarp(placed.warp);
1104
1774
  desc.quiltWarp = quiltWarp;
@@ -1184,7 +1854,7 @@ addHandler('Anno', function (target) { return target.annotations !== undefined;
1184
1854
  var popupLocation = readRect(reader);
1185
1855
  var color = (0, psdReader_1.readColor)(reader);
1186
1856
  var author = (0, psdReader_1.readPascalString)(reader, 2);
1187
- var name_1 = (0, psdReader_1.readPascalString)(reader, 2);
1857
+ var name_2 = (0, psdReader_1.readPascalString)(reader, 2);
1188
1858
  var date = (0, psdReader_1.readPascalString)(reader, 2);
1189
1859
  /*const contentLength =*/ (0, psdReader_1.readUint32)(reader);
1190
1860
  /*const dataType =*/ (0, psdReader_1.readSignature)(reader);
@@ -1213,7 +1883,7 @@ addHandler('Anno', function (target) { return target.annotations !== undefined;
1213
1883
  popupLocation: popupLocation,
1214
1884
  color: color,
1215
1885
  author: author,
1216
- name: name_1,
1886
+ name: name_2,
1217
1887
  date: date,
1218
1888
  data: data,
1219
1889
  });
@@ -1272,20 +1942,26 @@ addHandler('lnk2', function (target) { return !!target.linkedFiles && target.lin
1272
1942
  var type = (0, psdReader_1.readSignature)(reader);
1273
1943
  var version = (0, psdReader_1.readInt32)(reader);
1274
1944
  var id = (0, psdReader_1.readPascalString)(reader, 1);
1275
- var name_2 = (0, psdReader_1.readUnicodeString)(reader);
1945
+ var name_3 = (0, psdReader_1.readUnicodeString)(reader);
1276
1946
  var fileType = (0, psdReader_1.readSignature)(reader).trim(); // ' ' if empty
1277
1947
  var fileCreator = (0, psdReader_1.readSignature)(reader).trim(); // ' ' or '\0\0\0\0' if empty
1278
1948
  var dataSize = readLength64(reader);
1279
1949
  var hasFileOpenDescriptor = (0, psdReader_1.readUint8)(reader);
1280
1950
  var fileOpenDescriptor = hasFileOpenDescriptor ? (0, descriptor_1.readVersionAndDescriptor)(reader) : undefined;
1281
1951
  var linkedFileDescriptor = type === 'liFE' ? (0, descriptor_1.readVersionAndDescriptor)(reader) : undefined;
1282
- var file = { id: id, name: name_2, data: undefined };
1952
+ var file = { id: id, name: name_3, data: undefined };
1283
1953
  if (fileType)
1284
1954
  file.type = fileType;
1285
1955
  if (fileCreator)
1286
1956
  file.creator = fileCreator;
1287
- if (fileOpenDescriptor)
1288
- file.descriptor = fileOpenDescriptor;
1957
+ if (fileOpenDescriptor) {
1958
+ file.descriptor = {
1959
+ compInfo: {
1960
+ compID: fileOpenDescriptor.compInfo.compID,
1961
+ originalCompID: fileOpenDescriptor.compInfo.originalCompID,
1962
+ }
1963
+ };
1964
+ }
1289
1965
  if (type === 'liFE' && version > 3) {
1290
1966
  var year = (0, psdReader_1.readInt32)(reader);
1291
1967
  var month = (0, psdReader_1.readUint8)(reader);
@@ -1343,7 +2019,10 @@ addHandler('lnk2', function (target) { return !!target.linkedFiles && target.lin
1343
2019
  writeLength64(writer, file.data ? file.data.byteLength : 0);
1344
2020
  if (file.descriptor && file.descriptor.compInfo) {
1345
2021
  var desc = {
1346
- compInfo: file.descriptor.compInfo,
2022
+ compInfo: {
2023
+ compID: file.descriptor.compInfo.compID,
2024
+ originalCompID: file.descriptor.compInfo.originalCompID,
2025
+ }
1347
2026
  };
1348
2027
  (0, psdWriter_1.writeUint8)(writer, 1);
1349
2028
  (0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
@@ -2083,6 +2762,94 @@ addHandler('Txt2', hasKey('engineData'), function (reader, target, left) {
2083
2762
  var buffer = (0, base64_js_1.toByteArray)(target.engineData);
2084
2763
  (0, psdWriter_1.writeBytes)(writer, buffer);
2085
2764
  });
2765
+ addHandler('FEid', hasKey('filterEffectsMasks'), function (reader, target, leftBytes) {
2766
+ var version = (0, psdReader_1.readInt32)(reader);
2767
+ if (version < 1 || version > 3)
2768
+ throw new Error("Invalid filterEffects version ".concat(version));
2769
+ if ((0, psdReader_1.readUint32)(reader))
2770
+ throw new Error('filterEffects: 64 bit length is not supported');
2771
+ var length = (0, psdReader_1.readUint32)(reader);
2772
+ var end = reader.offset + length;
2773
+ target.filterEffectsMasks = [];
2774
+ while (reader.offset < end) {
2775
+ var id = (0, psdReader_1.readPascalString)(reader, 1);
2776
+ var effectVersion = (0, psdReader_1.readInt32)(reader);
2777
+ if (effectVersion !== 1)
2778
+ throw new Error("Invalid filterEffect version ".concat(effectVersion));
2779
+ if ((0, psdReader_1.readUint32)(reader))
2780
+ throw new Error('filterEffect: 64 bit length is not supported');
2781
+ /*const effectLength =*/ (0, psdReader_1.readUint32)(reader);
2782
+ // const endOfEffect = reader.offset + effectLength;
2783
+ var top_2 = (0, psdReader_1.readInt32)(reader);
2784
+ var left = (0, psdReader_1.readInt32)(reader);
2785
+ var bottom = (0, psdReader_1.readInt32)(reader);
2786
+ var right = (0, psdReader_1.readInt32)(reader);
2787
+ var depth = (0, psdReader_1.readInt32)(reader);
2788
+ var maxChannels = (0, psdReader_1.readInt32)(reader);
2789
+ var channels = [];
2790
+ // 0 -> R, 1 -> G, 2 -> B, 25 -> A
2791
+ for (var i = 0; i < (maxChannels + 2); i++) {
2792
+ var exists = (0, psdReader_1.readInt32)(reader);
2793
+ if (exists) {
2794
+ if ((0, psdReader_1.readUint32)(reader))
2795
+ throw new Error('filterEffect: 64 bit length is not supported');
2796
+ var channelLength = (0, psdReader_1.readUint32)(reader);
2797
+ var compressionMode = (0, psdReader_1.readUint16)(reader);
2798
+ var data = (0, psdReader_1.readBytes)(reader, channelLength - 2);
2799
+ channels.push({ compressionMode: compressionMode, data: data });
2800
+ }
2801
+ else {
2802
+ channels.push(undefined);
2803
+ }
2804
+ }
2805
+ target.filterEffectsMasks.push({ id: id, top: top_2, left: left, bottom: bottom, right: right, depth: depth, channels: channels });
2806
+ if (leftBytes() && (0, psdReader_1.readUint8)(reader)) {
2807
+ var compressionMode = (0, psdReader_1.readUint16)(reader);
2808
+ var data = (0, psdReader_1.readBytes)(reader, leftBytes());
2809
+ target.filterEffectsMasks[target.filterEffectsMasks.length - 1].extra = { compressionMode: compressionMode, data: data };
2810
+ }
2811
+ }
2812
+ }, function (writer, target) {
2813
+ var _a;
2814
+ (0, psdWriter_1.writeInt32)(writer, 3);
2815
+ (0, psdWriter_1.writeUint32)(writer, 0);
2816
+ (0, psdWriter_1.writeUint32)(writer, 0);
2817
+ var lengthOffset = writer.offset;
2818
+ for (var _i = 0, _b = target.filterEffectsMasks; _i < _b.length; _i++) {
2819
+ var mask = _b[_i];
2820
+ (0, psdWriter_1.writePascalString)(writer, mask.id, 1);
2821
+ (0, psdWriter_1.writeInt32)(writer, 1);
2822
+ (0, psdWriter_1.writeUint32)(writer, 0);
2823
+ (0, psdWriter_1.writeUint32)(writer, 0);
2824
+ var length2Offset = writer.offset;
2825
+ (0, psdWriter_1.writeInt32)(writer, mask.top);
2826
+ (0, psdWriter_1.writeInt32)(writer, mask.left);
2827
+ (0, psdWriter_1.writeInt32)(writer, mask.bottom);
2828
+ (0, psdWriter_1.writeInt32)(writer, mask.right);
2829
+ (0, psdWriter_1.writeInt32)(writer, mask.depth);
2830
+ var maxChannels = Math.max(0, mask.channels.length - 2);
2831
+ (0, psdWriter_1.writeInt32)(writer, maxChannels);
2832
+ for (var i = 0; i < (maxChannels + 2); i++) {
2833
+ var channel = mask.channels[i];
2834
+ (0, psdWriter_1.writeInt32)(writer, channel ? 1 : 0);
2835
+ if (channel) {
2836
+ (0, psdWriter_1.writeUint32)(writer, 0);
2837
+ (0, psdWriter_1.writeUint32)(writer, channel.data.length + 2);
2838
+ (0, psdWriter_1.writeUint16)(writer, channel.compressionMode);
2839
+ (0, psdWriter_1.writeBytes)(writer, channel.data);
2840
+ }
2841
+ }
2842
+ writer.view.setUint32(length2Offset - 4, writer.offset - length2Offset, false);
2843
+ }
2844
+ var extra = (_a = target.filterEffectsMasks[target.filterEffectsMasks.length - 1]) === null || _a === void 0 ? void 0 : _a.extra;
2845
+ if (extra) {
2846
+ (0, psdWriter_1.writeUint8)(writer, 1);
2847
+ (0, psdWriter_1.writeUint16)(writer, extra.compressionMode);
2848
+ (0, psdWriter_1.writeBytes)(writer, extra.data);
2849
+ }
2850
+ writer.view.setUint32(lengthOffset - 4, writer.offset - lengthOffset, false);
2851
+ });
2852
+ addHandlerAlias('FXid', 'FEid');
2086
2853
  addHandler('FMsk', hasKey('filterMask'), function (reader, target) {
2087
2854
  target.filterMask = {
2088
2855
  colorSpace: (0, psdReader_1.readColor)(reader),
@@ -2148,14 +2915,17 @@ addHandler('lfx2', function (target) { return target.effects !== undefined && !h
2148
2915
  addHandler('cinf', hasKey('compositorUsed'), function (reader, target, left) {
2149
2916
  var desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
2150
2917
  // console.log(require('util').inspect(desc, false, 99, true));
2918
+ function enumValue(desc) {
2919
+ return desc.split('.')[1];
2920
+ }
2151
2921
  target.compositorUsed = {
2152
2922
  description: desc.description,
2153
2923
  reason: desc.reason,
2154
- engine: desc.Engn.split('.')[1],
2155
- enableCompCore: desc.enableCompCore.split('.')[1],
2156
- enableCompCoreGPU: desc.enableCompCoreGPU.split('.')[1],
2157
- compCoreSupport: desc.compCoreSupport.split('.')[1],
2158
- compCoreGPUSupport: desc.compCoreGPUSupport.split('.')[1],
2924
+ engine: enumValue(desc.Engn),
2925
+ enableCompCore: enumValue(desc.enableCompCore),
2926
+ enableCompCoreGPU: enumValue(desc.enableCompCoreGPU),
2927
+ compCoreSupport: enumValue(desc.compCoreSupport),
2928
+ compCoreGPUSupport: enumValue(desc.compCoreGPUSupport),
2159
2929
  };
2160
2930
  (0, psdReader_1.skipBytes)(reader, left());
2161
2931
  }, function (writer, target) {
@@ -2210,85 +2980,4 @@ addHandler('tsly', hasKey('transparencyShapesLayer'), function (reader, target)
2210
2980
  (0, psdWriter_1.writeUint8)(writer, target.transparencyShapesLayer ? 1 : 0);
2211
2981
  (0, psdWriter_1.writeZeros)(writer, 3);
2212
2982
  });
2213
- /*addHandler(
2214
- 'FEid',
2215
- hasKey('filterEffects'),
2216
- (reader, _target) => {
2217
- const version = readInt32(reader);
2218
- if (version < 1 || version > 3) throw new Error(`Invalid filterEffects version ${version}`);
2219
-
2220
- if (readUint32(reader)) throw new Error('filterEffects: 64 bit length is not supported');
2221
- const length = readUint32(reader);
2222
- const end = reader.offset + length;
2223
-
2224
- while (reader.offset < end) {
2225
- console.log('bytes to go', end - reader.offset, 'at', reader.offset.toString(16));
2226
- //
2227
- const id = readPascalString(reader, 1);
2228
- const effectVersion = readInt32(reader);
2229
- if (effectVersion !== 1) throw new Error(`Invalid filterEffect version ${effectVersion}`);
2230
- if (readUint32(reader)) throw new Error('filterEffect: 64 bit length is not supported');
2231
- const effectLength = readUint32(reader);
2232
- const endOfEffect = reader.offset + effectLength;
2233
- const top = readInt32(reader);
2234
- const left = readInt32(reader);
2235
- const bottom = readInt32(reader);
2236
- const right = readInt32(reader);
2237
- const depth = readInt32(reader);
2238
- const maxChannels = readInt32(reader);
2239
- const channels: any[] = [];
2240
-
2241
- for (let i = 0; i < (maxChannels + 2); i++) {
2242
- const exists = readInt32(reader);
2243
- if (exists) {
2244
- if (readUint32(reader)) throw new Error('filterEffect: 64 bit length is not supported');
2245
- const channelLength = readUint32(reader);
2246
- const compressionMode = readUint16(reader);
2247
- const data = readBytes(reader, channelLength - 2);
2248
- channels.push({ channelLength, compressionMode, data: data?.length + ' bytes' });
2249
- // if (c < 3 || c == 25) e_ = _F.Cn(!0, rL, m, b.rect.F, b.rect.V, X, rp);
2250
- // if (c == 0) _c.S = e_;
2251
- // if (c == 1) _c.v = e_;
2252
- // if (c == 2) _c.e = e_;
2253
- // if (c == 25) _c.w = e_;
2254
- } else {
2255
- channels.push(undefined);
2256
- }
2257
- }
2258
-
2259
- console.log('left at the end', endOfEffect - reader.offset);
2260
- if (endOfEffect > reader.offset) {
2261
- if (readUint8(reader)) {
2262
- const compressionMode = readUint16(reader);
2263
- const data = endOfEffect > reader.offset ? readBytes(reader, endOfEffect - reader.offset) : undefined;
2264
- console.log('extra data', { compressionMode, data: data?.length + ' bytes' });
2265
- } else {
2266
- console.log('no extra');
2267
- }
2268
- }
2269
-
2270
- console.log('effect', {
2271
- id,
2272
- effectVersion,
2273
- effectLength,
2274
- top,
2275
- left,
2276
- bottom,
2277
- right,
2278
- depth,
2279
- maxChannels,
2280
- channels,
2281
- });
2282
-
2283
- console.log('bytes left after effect', endOfEffect - reader.offset);
2284
- // if (length % 4) skipBytes(reader, 4 - length % 4);
2285
- }
2286
-
2287
- console.log({ version, length });
2288
- },
2289
- (_writer, _target) => {
2290
- },
2291
- );
2292
-
2293
- addHandlerAlias('FXid', 'FEid');*/
2294
2983
  //# sourceMappingURL=additionalInfo.js.map