ag-psd 30.2.0 → 31.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/.v8-cache/v24.13.1-x64-cf738c9d/01e5e61b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/05135617 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/06423db9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/06e765df +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0930679d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/09519a62 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0a6607b0 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0ad8fa6e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0d390e10 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0dfa7b16 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/0e9e09db +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1130885f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1222cb8c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/15e2c039 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1a2d469d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1b300c82 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1bc3d370 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1e44e5af +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1efa10a1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/1f6c8743 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/20b27e40 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/257c62ba +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/25d60154 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/26f822f3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2a1e2a8d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2b02fded +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2c76dc0d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/2deb286a +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/32018e44 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/341402c3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/34e0fa2e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/3bbf643e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/3ceff89e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/404f5cdc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4087aa2b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4376c1f9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/44903df4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/44d58dc8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4511bacf +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/47da0ce8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/48cd54a9 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4d938476 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4ec6d390 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/4f5702bd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/514cc428 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/557d3b42 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/56abbff7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/57b540ee +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/5e20c081 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/651c4ada +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/652a0d59 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6a0e89ee +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6af33b91 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6c2562d2 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6dae0cfa +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/6e2529ce +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/71df9cb3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/72e1d543 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/75519c80 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/79bf115c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7a39347c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7b83e3d3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7cd71bc5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7da78512 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/7ea06cea +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/82c3b573 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/84c186e4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8607bd36 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/87372817 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/87cf2209 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/882aaa05 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8a4d3de8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/8e223473 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/92b7aefd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/932f0770 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/937c03a1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/991e4758 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9af658fb +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9ed80ba5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/9f0dc993 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a19c0c4f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a6409d95 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/a7e80865 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ac9802c6 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/acc36e66 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ad11e2dc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b0c8fcd8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b1762958 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b3c2fab7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b5b3329b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/b806679e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/bc1cdd48 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/bc7ebd1d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c0b789d2 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c314aece +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c399a5dc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c681cbc8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c6834ffc +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/c6f12ed5 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cb0f0a3d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cbcb7c95 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cdd9107c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cdf2c4a3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cfc49f4f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/cff9434a +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d02dd6f7 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d0507bf3 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d60fce19 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d733d619 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/d75b7803 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/dc86f000 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/defa4f7f +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e03e2acd +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e0e3f52c +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e158d332 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6735171 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6745c2b +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6b99945 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e6d8ceb8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/e7ffec37 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ea33b6de +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/eaafa3c4 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ebb50fca +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ec805f2e +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/edaef8f1 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/ee4401c8 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/eeeebdfe +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/f3d51676 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/f7b50a75 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fa58ca72 +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fc97d72d +0 -0
- package/.v8-cache/v24.13.1-x64-cf738c9d/fd0a2987 +0 -0
- package/CHANGELOG.md +6 -0
- package/README.md +64 -0
- package/TODO.md +2 -0
- package/dist/abr.d.ts +196 -196
- package/dist/abr.js +364 -365
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.d.ts +26 -26
- package/dist/additionalInfo.js +3478 -3478
- package/dist/additionalInfo.js.map +1 -1
- package/dist/ase.d.ts +32 -32
- package/dist/ase.js +81 -82
- package/dist/ase.js.map +1 -1
- package/dist/bundle.js +12380 -12259
- package/dist/csh.d.ts +10 -10
- package/dist/csh.js +35 -36
- package/dist/csh.js.map +1 -1
- package/dist/descriptor.d.ts +601 -601
- package/dist/descriptor.js +2003 -2003
- package/dist/descriptor.js.map +1 -1
- package/dist/effectsHelpers.d.ts +5 -5
- package/dist/effectsHelpers.js +286 -287
- package/dist/effectsHelpers.js.map +1 -1
- package/dist/engineData.d.ts +2 -2
- package/dist/engineData.js +334 -335
- package/dist/engineData.js.map +1 -1
- package/dist/engineData2.d.ts +2 -2
- package/dist/engineData2.js +409 -410
- package/dist/engineData2.js.map +1 -1
- package/dist/helpers.d.ts +74 -74
- package/dist/helpers.js +353 -342
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.d.ts +17 -17
- package/dist/imageResources.js +1040 -1040
- package/dist/imageResources.js.map +1 -1
- package/dist/index.d.ts +20 -22
- package/dist/index.js +61 -56
- package/dist/index.js.map +1 -1
- package/dist/initializeCanvas.d.ts +1 -1
- package/dist/initializeCanvas.js +9 -10
- package/dist/initializeCanvas.js.map +1 -1
- package/dist/jpeg.d.ts +1 -1
- package/dist/jpeg.js +1020 -1021
- package/dist/jpeg.js.map +1 -1
- package/dist/psd.d.ts +1877 -1873
- package/dist/psd.js +45 -45
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.d.ts +52 -45
- package/dist/psdReader.js +1385 -1282
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +34 -34
- package/dist/psdWriter.js +834 -824
- package/dist/psdWriter.js.map +1 -1
- package/dist/text.d.ts +179 -179
- package/dist/text.js +552 -553
- package/dist/text.js.map +1 -1
- package/dist/utf8.d.ts +4 -6
- package/dist/utf8.js +156 -157
- package/dist/utf8.js.map +1 -1
- package/dist-es/abr.d.ts +196 -196
- package/dist-es/abr.js +364 -361
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.d.ts +26 -26
- package/dist-es/additionalInfo.js +3478 -3472
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/ase.d.ts +32 -32
- package/dist-es/ase.js +81 -78
- package/dist-es/ase.js.map +1 -1
- package/dist-es/csh.d.ts +10 -10
- package/dist-es/csh.js +35 -32
- package/dist-es/csh.js.map +1 -1
- package/dist-es/descriptor.d.ts +601 -601
- package/dist-es/descriptor.js +2003 -1970
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/effectsHelpers.d.ts +5 -5
- package/dist-es/effectsHelpers.js +286 -282
- package/dist-es/effectsHelpers.js.map +1 -1
- package/dist-es/engineData.d.ts +2 -2
- package/dist-es/engineData.js +334 -330
- package/dist-es/engineData.js.map +1 -1
- package/dist-es/engineData2.d.ts +2 -2
- package/dist-es/engineData2.js +409 -406
- package/dist-es/engineData2.js.map +1 -1
- package/dist-es/helpers.d.ts +74 -74
- package/dist-es/helpers.js +353 -324
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.d.ts +17 -17
- package/dist-es/imageResources.js +1040 -1037
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/index.d.ts +20 -22
- package/dist-es/index.js +61 -33
- package/dist-es/index.js.map +1 -1
- package/dist-es/initializeCanvas.d.ts +1 -1
- package/dist-es/initializeCanvas.js +9 -6
- package/dist-es/initializeCanvas.js.map +1 -1
- package/dist-es/jpeg.d.ts +1 -1
- package/dist-es/jpeg.js +1020 -1017
- package/dist-es/jpeg.js.map +1 -1
- package/dist-es/psd.d.ts +1877 -1873
- package/dist-es/psd.js +45 -42
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.d.ts +52 -45
- package/dist-es/psdReader.js +1385 -1244
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +34 -34
- package/dist-es/psdWriter.js +834 -794
- package/dist-es/psdWriter.js.map +1 -1
- package/dist-es/text.d.ts +179 -179
- package/dist-es/text.js +552 -548
- package/dist-es/text.js.map +1 -1
- package/dist-es/utf8.d.ts +4 -6
- package/dist-es/utf8.js +156 -150
- package/dist-es/utf8.js.map +1 -1
- package/package.json +4 -3
- package/src/helpers.ts +13 -3
- package/src/index.ts +4 -6
- package/src/psd.ts +4 -0
- package/src/psdReader.ts +136 -43
- package/src/psdWriter.ts +42 -23
- package/tsconfig-es6.json +2 -1
- package/tsconfig.json +1 -0
|
@@ -1,1038 +1,1041 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
info.proofSetup = {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
desc.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
writeFixedPoint32(writer, info.
|
|
194
|
-
writeUint16(writer, Math.max(1, RESOLUTION_UNITS.indexOf(info.
|
|
195
|
-
writeUint16(writer, Math.max(1, MEASUREMENT_UNITS.indexOf(info.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
target.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
addHandler(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
writeUint8(writer, flags.
|
|
277
|
-
writeUint8(writer, flags.
|
|
278
|
-
writeUint8(writer, flags.
|
|
279
|
-
writeUint8(writer, flags.
|
|
280
|
-
writeUint8(writer, flags.
|
|
281
|
-
writeUint8(writer, flags.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
'
|
|
341
|
-
'
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
writeUint32(writer,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
t
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
desc.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
},
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
}
|
|
632
|
-
function
|
|
633
|
-
return {
|
|
634
|
-
}
|
|
635
|
-
function
|
|
636
|
-
return
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
const
|
|
652
|
-
const
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const
|
|
661
|
-
const
|
|
662
|
-
const
|
|
663
|
-
const
|
|
664
|
-
const
|
|
665
|
-
const
|
|
666
|
-
const
|
|
667
|
-
const
|
|
668
|
-
const
|
|
669
|
-
const
|
|
670
|
-
const
|
|
671
|
-
const
|
|
672
|
-
const
|
|
673
|
-
const
|
|
674
|
-
const
|
|
675
|
-
const
|
|
676
|
-
const
|
|
677
|
-
const
|
|
678
|
-
const
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
slice.
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
writeInt32(writer, bounds.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
a = 0;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
writeInt32(writer, slice.bounds.
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
writeUnicodeString(writer, slice.
|
|
745
|
-
|
|
746
|
-
writeUnicodeString(writer, slice.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
writeUint8(writer,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
slice.
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
})
|
|
780
|
-
|
|
781
|
-
target.
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
readUint32(reader); //
|
|
800
|
-
readUint32(reader);
|
|
801
|
-
readUint32(reader);
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
target.
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
const
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
writeUint32(writer,
|
|
847
|
-
writeUint32(writer,
|
|
848
|
-
writeUint32(writer,
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
const desc =
|
|
895
|
-
|
|
896
|
-
})
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
reader.
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
reader.
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
//
|
|
997
|
-
//
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
});
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
reader.
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resourceHandlersMap = exports.resourceHandlers = void 0;
|
|
4
|
+
const base64_js_1 = require("base64-js");
|
|
5
|
+
const psdReader_1 = require("./psdReader");
|
|
6
|
+
const psdWriter_1 = require("./psdWriter");
|
|
7
|
+
const helpers_1 = require("./helpers");
|
|
8
|
+
const utf8_1 = require("./utf8");
|
|
9
|
+
const descriptor_1 = require("./descriptor");
|
|
10
|
+
exports.resourceHandlers = [];
|
|
11
|
+
exports.resourceHandlersMap = {};
|
|
12
|
+
function addHandler(key, has, read, write) {
|
|
13
|
+
const handler = { key, has, read, write };
|
|
14
|
+
exports.resourceHandlers.push(handler);
|
|
15
|
+
exports.resourceHandlersMap[handler.key] = handler;
|
|
16
|
+
}
|
|
17
|
+
const LOG_MOCK_HANDLERS = false;
|
|
18
|
+
const RESOLUTION_UNITS = [undefined, 'PPI', 'PPCM'];
|
|
19
|
+
const MEASUREMENT_UNITS = [undefined, 'Inches', 'Centimeters', 'Points', 'Picas', 'Columns'];
|
|
20
|
+
const hex = '0123456789abcdef';
|
|
21
|
+
function charToNibble(code) {
|
|
22
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
23
|
+
}
|
|
24
|
+
function byteAt(value, index) {
|
|
25
|
+
return (charToNibble(value.charCodeAt(index)) << 4) | charToNibble(value.charCodeAt(index + 1));
|
|
26
|
+
}
|
|
27
|
+
function readUtf8String(reader, length) {
|
|
28
|
+
const buffer = (0, psdReader_1.readBytes)(reader, length);
|
|
29
|
+
return (0, utf8_1.decodeString)(buffer);
|
|
30
|
+
}
|
|
31
|
+
function writeUtf8String(writer, value) {
|
|
32
|
+
const buffer = (0, utf8_1.encodeString)(value);
|
|
33
|
+
(0, psdWriter_1.writeBytes)(writer, buffer);
|
|
34
|
+
}
|
|
35
|
+
function readEncodedString(reader) {
|
|
36
|
+
const length = (0, psdReader_1.readUint8)(reader);
|
|
37
|
+
const buffer = (0, psdReader_1.readBytes)(reader, length);
|
|
38
|
+
let notAscii = false;
|
|
39
|
+
for (let i = 0; i < buffer.byteLength; i++) {
|
|
40
|
+
if (buffer[i] & 0x80) {
|
|
41
|
+
notAscii = true;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (notAscii) {
|
|
46
|
+
const decoder = new TextDecoder('gbk');
|
|
47
|
+
return decoder.decode(buffer);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return (0, utf8_1.decodeString)(buffer);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function writeEncodedString(writer, value) {
|
|
54
|
+
let ascii = '';
|
|
55
|
+
for (let i = 0, code = value.codePointAt(i++); code !== undefined; code = value.codePointAt(i++)) {
|
|
56
|
+
ascii += code > 0x7f ? '?' : String.fromCodePoint(code);
|
|
57
|
+
}
|
|
58
|
+
const buffer = (0, utf8_1.encodeString)(ascii);
|
|
59
|
+
(0, psdWriter_1.writeUint8)(writer, buffer.byteLength);
|
|
60
|
+
(0, psdWriter_1.writeBytes)(writer, buffer);
|
|
61
|
+
}
|
|
62
|
+
helpers_1.MOCK_HANDLERS && addHandler(1028, // IPTC-NAA record
|
|
63
|
+
// IPTC-NAA record
|
|
64
|
+
target => target._ir1028 !== undefined, (reader, target, left) => {
|
|
65
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1028', left());
|
|
66
|
+
target._ir1028 = (0, psdReader_1.readBytes)(reader, left());
|
|
67
|
+
}, (writer, target) => {
|
|
68
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1028);
|
|
69
|
+
});
|
|
70
|
+
addHandler(1061, target => target.captionDigest !== undefined, (reader, target) => {
|
|
71
|
+
let captionDigest = '';
|
|
72
|
+
for (let i = 0; i < 16; i++) {
|
|
73
|
+
const byte = (0, psdReader_1.readUint8)(reader);
|
|
74
|
+
captionDigest += hex[byte >> 4];
|
|
75
|
+
captionDigest += hex[byte & 0xf];
|
|
76
|
+
}
|
|
77
|
+
target.captionDigest = captionDigest;
|
|
78
|
+
}, (writer, target) => {
|
|
79
|
+
for (let i = 0; i < 16; i++) {
|
|
80
|
+
(0, psdWriter_1.writeUint8)(writer, byteAt(target.captionDigest, i * 2));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
addHandler(1060, target => target.xmpMetadata !== undefined, (reader, target, left) => {
|
|
84
|
+
target.xmpMetadata = readUtf8String(reader, left());
|
|
85
|
+
}, (writer, target) => {
|
|
86
|
+
writeUtf8String(writer, target.xmpMetadata);
|
|
87
|
+
});
|
|
88
|
+
const Inte = (0, helpers_1.createEnum)('Inte', 'perceptual', {
|
|
89
|
+
'perceptual': 'Img ',
|
|
90
|
+
'saturation': 'Grp ',
|
|
91
|
+
'relative colorimetric': 'Clrm',
|
|
92
|
+
'absolute colorimetric': 'AClr',
|
|
93
|
+
});
|
|
94
|
+
helpers_1.MOCK_HANDLERS && addHandler(1085, // Windows DEVMODE. Variable OS specific info for Windows.
|
|
95
|
+
// Windows DEVMODE. Variable OS specific info for Windows.
|
|
96
|
+
target => target._ir1085 !== undefined, (reader, target, left) => {
|
|
97
|
+
target._ir1085 = (0, psdReader_1.readBytes)(reader, left());
|
|
98
|
+
}, (writer, target) => {
|
|
99
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1085);
|
|
100
|
+
});
|
|
101
|
+
addHandler(1082, target => target.printInformation !== undefined, (reader, target) => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
104
|
+
target.printInformation = {
|
|
105
|
+
printerName: desc.printerName || '',
|
|
106
|
+
renderingIntent: Inte.decode((_a = desc.Inte) !== null && _a !== void 0 ? _a : 'Inte.Img '),
|
|
107
|
+
};
|
|
108
|
+
const info = target.printInformation;
|
|
109
|
+
if (desc.PstS !== undefined)
|
|
110
|
+
info.printerManagesColors = desc.PstS;
|
|
111
|
+
if (desc['Nm '] !== undefined)
|
|
112
|
+
info.printerProfile = desc['Nm '];
|
|
113
|
+
if (desc.MpBl !== undefined)
|
|
114
|
+
info.blackPointCompensation = desc.MpBl;
|
|
115
|
+
if (desc.printSixteenBit !== undefined)
|
|
116
|
+
info.printSixteenBit = desc.printSixteenBit;
|
|
117
|
+
if (desc.hardProof !== undefined)
|
|
118
|
+
info.hardProof = desc.hardProof;
|
|
119
|
+
if (desc.printProofSetup) {
|
|
120
|
+
if ('Bltn' in desc.printProofSetup) {
|
|
121
|
+
info.proofSetup = { builtin: desc.printProofSetup.Bltn.split('.')[1] };
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
info.proofSetup = {
|
|
125
|
+
profile: desc.printProofSetup.profile,
|
|
126
|
+
renderingIntent: Inte.decode((_b = desc.printProofSetup.Inte) !== null && _b !== void 0 ? _b : 'Inte.Img '),
|
|
127
|
+
blackPointCompensation: !!desc.printProofSetup.MpBl,
|
|
128
|
+
paperWhite: !!desc.printProofSetup.paperWhite,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, (writer, target) => {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
const info = target.printInformation;
|
|
135
|
+
const desc = {};
|
|
136
|
+
if (info.printerManagesColors) {
|
|
137
|
+
desc.PstS = true;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
if (info.hardProof !== undefined)
|
|
141
|
+
desc.hardProof = !!info.hardProof;
|
|
142
|
+
desc.ClrS = 'ClrS.RGBC'; // TODO: ???
|
|
143
|
+
desc['Nm '] = (_a = info.printerProfile) !== null && _a !== void 0 ? _a : 'CIE RGB';
|
|
144
|
+
}
|
|
145
|
+
desc.Inte = Inte.encode(info.renderingIntent);
|
|
146
|
+
if (!info.printerManagesColors)
|
|
147
|
+
desc.MpBl = !!info.blackPointCompensation;
|
|
148
|
+
desc.printSixteenBit = !!info.printSixteenBit;
|
|
149
|
+
desc.printerName = info.printerName || '';
|
|
150
|
+
if (info.proofSetup && 'profile' in info.proofSetup) {
|
|
151
|
+
desc.printProofSetup = {
|
|
152
|
+
profile: info.proofSetup.profile || '',
|
|
153
|
+
Inte: Inte.encode(info.proofSetup.renderingIntent),
|
|
154
|
+
MpBl: !!info.proofSetup.blackPointCompensation,
|
|
155
|
+
paperWhite: !!info.proofSetup.paperWhite,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
desc.printProofSetup = {
|
|
160
|
+
Bltn: ((_b = info.proofSetup) === null || _b === void 0 ? void 0 : _b.builtin) ? `builtinProof.${info.proofSetup.builtin}` : 'builtinProof.proofCMYK',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'printOutput', desc);
|
|
164
|
+
});
|
|
165
|
+
helpers_1.MOCK_HANDLERS && addHandler(1083, // Print style
|
|
166
|
+
// Print style
|
|
167
|
+
target => target._ir1083 !== undefined, (reader, target, left) => {
|
|
168
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1083', left());
|
|
169
|
+
target._ir1083 = (0, psdReader_1.readBytes)(reader, left());
|
|
170
|
+
// TODO:
|
|
171
|
+
// const desc = readVersionAndDescriptor(reader);
|
|
172
|
+
// console.log('1083', require('util').inspect(desc, false, 99, true));
|
|
173
|
+
}, (writer, target) => {
|
|
174
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1083);
|
|
175
|
+
});
|
|
176
|
+
addHandler(1005, target => target.resolutionInfo !== undefined, (reader, target) => {
|
|
177
|
+
const horizontalResolution = (0, psdReader_1.readFixedPoint32)(reader);
|
|
178
|
+
const horizontalResolutionUnit = (0, psdReader_1.readUint16)(reader);
|
|
179
|
+
const widthUnit = (0, psdReader_1.readUint16)(reader);
|
|
180
|
+
const verticalResolution = (0, psdReader_1.readFixedPoint32)(reader);
|
|
181
|
+
const verticalResolutionUnit = (0, psdReader_1.readUint16)(reader);
|
|
182
|
+
const heightUnit = (0, psdReader_1.readUint16)(reader);
|
|
183
|
+
target.resolutionInfo = {
|
|
184
|
+
horizontalResolution,
|
|
185
|
+
horizontalResolutionUnit: RESOLUTION_UNITS[horizontalResolutionUnit] || 'PPI',
|
|
186
|
+
widthUnit: MEASUREMENT_UNITS[widthUnit] || 'Inches',
|
|
187
|
+
verticalResolution,
|
|
188
|
+
verticalResolutionUnit: RESOLUTION_UNITS[verticalResolutionUnit] || 'PPI',
|
|
189
|
+
heightUnit: MEASUREMENT_UNITS[heightUnit] || 'Inches',
|
|
190
|
+
};
|
|
191
|
+
}, (writer, target) => {
|
|
192
|
+
const info = target.resolutionInfo;
|
|
193
|
+
(0, psdWriter_1.writeFixedPoint32)(writer, info.horizontalResolution || 0);
|
|
194
|
+
(0, psdWriter_1.writeUint16)(writer, Math.max(1, RESOLUTION_UNITS.indexOf(info.horizontalResolutionUnit)));
|
|
195
|
+
(0, psdWriter_1.writeUint16)(writer, Math.max(1, MEASUREMENT_UNITS.indexOf(info.widthUnit)));
|
|
196
|
+
(0, psdWriter_1.writeFixedPoint32)(writer, info.verticalResolution || 0);
|
|
197
|
+
(0, psdWriter_1.writeUint16)(writer, Math.max(1, RESOLUTION_UNITS.indexOf(info.verticalResolutionUnit)));
|
|
198
|
+
(0, psdWriter_1.writeUint16)(writer, Math.max(1, MEASUREMENT_UNITS.indexOf(info.heightUnit)));
|
|
199
|
+
});
|
|
200
|
+
const printScaleStyles = ['centered', 'size to fit', 'user defined'];
|
|
201
|
+
addHandler(1062, target => target.printScale !== undefined, (reader, target) => {
|
|
202
|
+
target.printScale = {
|
|
203
|
+
style: printScaleStyles[(0, psdReader_1.readInt16)(reader)],
|
|
204
|
+
x: (0, psdReader_1.readFloat32)(reader),
|
|
205
|
+
y: (0, psdReader_1.readFloat32)(reader),
|
|
206
|
+
scale: (0, psdReader_1.readFloat32)(reader),
|
|
207
|
+
};
|
|
208
|
+
}, (writer, target) => {
|
|
209
|
+
const { style, x, y, scale } = target.printScale;
|
|
210
|
+
(0, psdWriter_1.writeInt16)(writer, Math.max(0, printScaleStyles.indexOf(style)));
|
|
211
|
+
(0, psdWriter_1.writeFloat32)(writer, x || 0);
|
|
212
|
+
(0, psdWriter_1.writeFloat32)(writer, y || 0);
|
|
213
|
+
(0, psdWriter_1.writeFloat32)(writer, scale || 0);
|
|
214
|
+
});
|
|
215
|
+
addHandler(1006, target => target.alphaChannelNames !== undefined, (reader, target, left) => {
|
|
216
|
+
if (!target.alphaChannelNames) { // skip if the unicode versions are already read
|
|
217
|
+
target.alphaChannelNames = [];
|
|
218
|
+
while (left() > 0) {
|
|
219
|
+
const value = readEncodedString(reader);
|
|
220
|
+
// const value = readPascalString(reader, 1);
|
|
221
|
+
target.alphaChannelNames.push(value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
(0, psdReader_1.skipBytes)(reader, left());
|
|
226
|
+
}
|
|
227
|
+
}, (writer, target) => {
|
|
228
|
+
for (const name of target.alphaChannelNames) {
|
|
229
|
+
writeEncodedString(writer, name);
|
|
230
|
+
// writePascalString(writer, name, 1);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
addHandler(1045, target => target.alphaChannelNames !== undefined, (reader, target, left) => {
|
|
234
|
+
target.alphaChannelNames = [];
|
|
235
|
+
while (left() > 0) {
|
|
236
|
+
target.alphaChannelNames.push((0, psdReader_1.readUnicodeString)(reader));
|
|
237
|
+
}
|
|
238
|
+
}, (writer, target) => {
|
|
239
|
+
for (const name of target.alphaChannelNames) {
|
|
240
|
+
(0, psdWriter_1.writeUnicodeStringWithPadding)(writer, name);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
helpers_1.MOCK_HANDLERS && addHandler(1077, target => target._ir1077 !== undefined, (reader, target, left) => {
|
|
244
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1077', left());
|
|
245
|
+
target._ir1077 = (0, psdReader_1.readBytes)(reader, left());
|
|
246
|
+
}, (writer, target) => {
|
|
247
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1077);
|
|
248
|
+
});
|
|
249
|
+
addHandler(1053, target => target.alphaIdentifiers !== undefined, (reader, target, left) => {
|
|
250
|
+
target.alphaIdentifiers = [];
|
|
251
|
+
while (left() >= 4) {
|
|
252
|
+
target.alphaIdentifiers.push((0, psdReader_1.readUint32)(reader));
|
|
253
|
+
}
|
|
254
|
+
}, (writer, target) => {
|
|
255
|
+
for (const id of target.alphaIdentifiers) {
|
|
256
|
+
(0, psdWriter_1.writeUint32)(writer, id);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
addHandler(1010, target => target.backgroundColor !== undefined, (reader, target) => target.backgroundColor = (0, psdReader_1.readColor)(reader), (writer, target) => (0, psdWriter_1.writeColor)(writer, target.backgroundColor));
|
|
260
|
+
addHandler(1037, target => target.globalAngle !== undefined, (reader, target) => target.globalAngle = (0, psdReader_1.readInt32)(reader), (writer, target) => (0, psdWriter_1.writeInt32)(writer, target.globalAngle));
|
|
261
|
+
addHandler(1049, target => target.globalAltitude !== undefined, (reader, target) => target.globalAltitude = (0, psdReader_1.readUint32)(reader), (writer, target) => (0, psdWriter_1.writeUint32)(writer, target.globalAltitude));
|
|
262
|
+
addHandler(1011, target => target.printFlags !== undefined, (reader, target) => {
|
|
263
|
+
target.printFlags = {
|
|
264
|
+
labels: !!(0, psdReader_1.readUint8)(reader),
|
|
265
|
+
cropMarks: !!(0, psdReader_1.readUint8)(reader),
|
|
266
|
+
colorBars: !!(0, psdReader_1.readUint8)(reader),
|
|
267
|
+
registrationMarks: !!(0, psdReader_1.readUint8)(reader),
|
|
268
|
+
negative: !!(0, psdReader_1.readUint8)(reader),
|
|
269
|
+
flip: !!(0, psdReader_1.readUint8)(reader),
|
|
270
|
+
interpolate: !!(0, psdReader_1.readUint8)(reader),
|
|
271
|
+
caption: !!(0, psdReader_1.readUint8)(reader),
|
|
272
|
+
printFlags: !!(0, psdReader_1.readUint8)(reader),
|
|
273
|
+
};
|
|
274
|
+
}, (writer, target) => {
|
|
275
|
+
const flags = target.printFlags;
|
|
276
|
+
(0, psdWriter_1.writeUint8)(writer, flags.labels ? 1 : 0);
|
|
277
|
+
(0, psdWriter_1.writeUint8)(writer, flags.cropMarks ? 1 : 0);
|
|
278
|
+
(0, psdWriter_1.writeUint8)(writer, flags.colorBars ? 1 : 0);
|
|
279
|
+
(0, psdWriter_1.writeUint8)(writer, flags.registrationMarks ? 1 : 0);
|
|
280
|
+
(0, psdWriter_1.writeUint8)(writer, flags.negative ? 1 : 0);
|
|
281
|
+
(0, psdWriter_1.writeUint8)(writer, flags.flip ? 1 : 0);
|
|
282
|
+
(0, psdWriter_1.writeUint8)(writer, flags.interpolate ? 1 : 0);
|
|
283
|
+
(0, psdWriter_1.writeUint8)(writer, flags.caption ? 1 : 0);
|
|
284
|
+
(0, psdWriter_1.writeUint8)(writer, flags.printFlags ? 1 : 0);
|
|
285
|
+
});
|
|
286
|
+
addHandler(1034, // Copyright flag
|
|
287
|
+
// Copyright flag
|
|
288
|
+
target => target.copyrighted !== undefined, (reader, target) => {
|
|
289
|
+
target.copyrighted = !!(0, psdReader_1.readUint8)(reader);
|
|
290
|
+
}, (writer, target) => {
|
|
291
|
+
(0, psdWriter_1.writeUint8)(writer, target.copyrighted ? 1 : 0);
|
|
292
|
+
});
|
|
293
|
+
addHandler(1035, // URL
|
|
294
|
+
// URL
|
|
295
|
+
target => target.url !== undefined, (reader, target, left) => {
|
|
296
|
+
target.url = (0, psdReader_1.readAsciiString)(reader, left());
|
|
297
|
+
}, (writer, target) => {
|
|
298
|
+
(0, psdWriter_1.writeAsciiString)(writer, target.url);
|
|
299
|
+
});
|
|
300
|
+
helpers_1.MOCK_HANDLERS && addHandler(10000, // Print flags
|
|
301
|
+
// Print flags
|
|
302
|
+
target => target._ir10000 !== undefined, (reader, target, left) => {
|
|
303
|
+
LOG_MOCK_HANDLERS && console.log('image resource 10000', left());
|
|
304
|
+
target._ir10000 = (0, psdReader_1.readBytes)(reader, left());
|
|
305
|
+
}, (writer, target) => {
|
|
306
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir10000);
|
|
307
|
+
});
|
|
308
|
+
helpers_1.MOCK_HANDLERS && addHandler(1013, // Color halftoning
|
|
309
|
+
// Color halftoning
|
|
310
|
+
target => target._ir1013 !== undefined, (reader, target, left) => {
|
|
311
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1013', left());
|
|
312
|
+
target._ir1013 = (0, psdReader_1.readBytes)(reader, left());
|
|
313
|
+
}, (writer, target) => {
|
|
314
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1013);
|
|
315
|
+
});
|
|
316
|
+
helpers_1.MOCK_HANDLERS && addHandler(1016, // Color transfer functions
|
|
317
|
+
// Color transfer functions
|
|
318
|
+
target => target._ir1016 !== undefined, (reader, target, left) => {
|
|
319
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1016', left());
|
|
320
|
+
target._ir1016 = (0, psdReader_1.readBytes)(reader, left());
|
|
321
|
+
}, (writer, target) => {
|
|
322
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1016);
|
|
323
|
+
});
|
|
324
|
+
addHandler(1080, // Count Information
|
|
325
|
+
// Count Information
|
|
326
|
+
target => target.countInformation !== undefined, (reader, target) => {
|
|
327
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
328
|
+
target.countInformation = desc.countGroupList.map(g => ({
|
|
329
|
+
color: { r: g['Rd '], g: g['Grn '], b: g['Bl '] },
|
|
330
|
+
name: g['Nm '],
|
|
331
|
+
size: g['Rds '],
|
|
332
|
+
fontSize: g.fontSize,
|
|
333
|
+
visible: g.Vsbl,
|
|
334
|
+
points: g.countObjectList.map(p => ({ x: p['X '], y: p['Y '] })),
|
|
335
|
+
}));
|
|
336
|
+
}, (writer, target) => {
|
|
337
|
+
const desc = {
|
|
338
|
+
Vrsn: 1,
|
|
339
|
+
countGroupList: target.countInformation.map(g => ({
|
|
340
|
+
'Rd ': g.color.r,
|
|
341
|
+
'Grn ': g.color.g,
|
|
342
|
+
'Bl ': g.color.b,
|
|
343
|
+
'Nm ': g.name,
|
|
344
|
+
'Rds ': g.size,
|
|
345
|
+
fontSize: g.fontSize,
|
|
346
|
+
Vsbl: g.visible,
|
|
347
|
+
countObjectList: g.points.map(p => ({ 'X ': p.x, 'Y ': p.y })),
|
|
348
|
+
})),
|
|
349
|
+
};
|
|
350
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'Cnt ', desc);
|
|
351
|
+
});
|
|
352
|
+
addHandler(1024, target => target.layerState !== undefined, (reader, target) => target.layerState = (0, psdReader_1.readUint16)(reader), (writer, target) => (0, psdWriter_1.writeUint16)(writer, target.layerState));
|
|
353
|
+
addHandler(1026, target => target.layersGroup !== undefined, (reader, target, left) => {
|
|
354
|
+
target.layersGroup = [];
|
|
355
|
+
while (left() > 0) {
|
|
356
|
+
target.layersGroup.push((0, psdReader_1.readUint16)(reader));
|
|
357
|
+
}
|
|
358
|
+
}, (writer, target) => {
|
|
359
|
+
for (const g of target.layersGroup) {
|
|
360
|
+
(0, psdWriter_1.writeUint16)(writer, g);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
addHandler(1072, target => target.layerGroupsEnabledId !== undefined, (reader, target, left) => {
|
|
364
|
+
target.layerGroupsEnabledId = [];
|
|
365
|
+
while (left() > 0) {
|
|
366
|
+
target.layerGroupsEnabledId.push((0, psdReader_1.readUint8)(reader));
|
|
367
|
+
}
|
|
368
|
+
}, (writer, target) => {
|
|
369
|
+
for (const id of target.layerGroupsEnabledId) {
|
|
370
|
+
(0, psdWriter_1.writeUint8)(writer, id);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
addHandler(1069, target => target.layerSelectionIds !== undefined, (reader, target) => {
|
|
374
|
+
let count = (0, psdReader_1.readUint16)(reader);
|
|
375
|
+
target.layerSelectionIds = [];
|
|
376
|
+
while (count--) {
|
|
377
|
+
target.layerSelectionIds.push((0, psdReader_1.readUint32)(reader));
|
|
378
|
+
}
|
|
379
|
+
}, (writer, target) => {
|
|
380
|
+
(0, psdWriter_1.writeUint16)(writer, target.layerSelectionIds.length);
|
|
381
|
+
for (const id of target.layerSelectionIds) {
|
|
382
|
+
(0, psdWriter_1.writeUint32)(writer, id);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
addHandler(1032, target => target.gridAndGuidesInformation !== undefined, (reader, target) => {
|
|
386
|
+
const version = (0, psdReader_1.readUint32)(reader);
|
|
387
|
+
const horizontal = (0, psdReader_1.readUint32)(reader);
|
|
388
|
+
const vertical = (0, psdReader_1.readUint32)(reader);
|
|
389
|
+
const count = (0, psdReader_1.readUint32)(reader);
|
|
390
|
+
if (version !== 1)
|
|
391
|
+
throw new Error(`Invalid 1032 resource version: ${version}`);
|
|
392
|
+
target.gridAndGuidesInformation = {
|
|
393
|
+
grid: { horizontal, vertical },
|
|
394
|
+
guides: [],
|
|
395
|
+
};
|
|
396
|
+
for (let i = 0; i < count; i++) {
|
|
397
|
+
target.gridAndGuidesInformation.guides.push({
|
|
398
|
+
location: (0, psdReader_1.readUint32)(reader) / 32,
|
|
399
|
+
direction: (0, psdReader_1.readUint8)(reader) ? 'horizontal' : 'vertical'
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}, (writer, target) => {
|
|
403
|
+
const info = target.gridAndGuidesInformation;
|
|
404
|
+
const grid = info.grid || { horizontal: 18 * 32, vertical: 18 * 32 };
|
|
405
|
+
const guides = info.guides || [];
|
|
406
|
+
(0, psdWriter_1.writeUint32)(writer, 1);
|
|
407
|
+
(0, psdWriter_1.writeUint32)(writer, grid.horizontal);
|
|
408
|
+
(0, psdWriter_1.writeUint32)(writer, grid.vertical);
|
|
409
|
+
(0, psdWriter_1.writeUint32)(writer, guides.length);
|
|
410
|
+
for (const g of guides) {
|
|
411
|
+
(0, psdWriter_1.writeUint32)(writer, g.location * 32);
|
|
412
|
+
(0, psdWriter_1.writeUint8)(writer, g.direction === 'horizontal' ? 1 : 0);
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
addHandler(1065, // Layer Comps
|
|
416
|
+
// Layer Comps
|
|
417
|
+
target => target.layerComps !== undefined, (reader, target) => {
|
|
418
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader, true);
|
|
419
|
+
// console.log('CompList', require('util').inspect(desc, false, 99, true));
|
|
420
|
+
target.layerComps = { list: [] };
|
|
421
|
+
for (const item of desc.list) {
|
|
422
|
+
target.layerComps.list.push({
|
|
423
|
+
id: item.compID,
|
|
424
|
+
name: item['Nm '],
|
|
425
|
+
capturedInfo: item.capturedInfo,
|
|
426
|
+
});
|
|
427
|
+
if ('comment' in item)
|
|
428
|
+
target.layerComps.list[target.layerComps.list.length - 1].comment = item.comment;
|
|
429
|
+
}
|
|
430
|
+
if ('lastAppliedComp' in desc)
|
|
431
|
+
target.layerComps.lastApplied = desc.lastAppliedComp;
|
|
432
|
+
}, (writer, target) => {
|
|
433
|
+
const layerComps = target.layerComps;
|
|
434
|
+
const desc = { list: [] };
|
|
435
|
+
for (const item of layerComps.list) {
|
|
436
|
+
const t = {};
|
|
437
|
+
t._classID = 'Comp';
|
|
438
|
+
t['Nm '] = item.name;
|
|
439
|
+
if ('comment' in item)
|
|
440
|
+
t.comment = item.comment;
|
|
441
|
+
t.compID = item.id;
|
|
442
|
+
t.capturedInfo = item.capturedInfo;
|
|
443
|
+
desc.list.push(t);
|
|
444
|
+
}
|
|
445
|
+
if ('lastApplied' in layerComps)
|
|
446
|
+
desc.lastAppliedComp = layerComps.lastApplied;
|
|
447
|
+
// console.log('CompList', require('util').inspect(desc, false, 99, true));
|
|
448
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'CompList', desc);
|
|
449
|
+
});
|
|
450
|
+
helpers_1.MOCK_HANDLERS && addHandler(1092, // ???
|
|
451
|
+
// ???
|
|
452
|
+
target => target._ir1092 !== undefined, (reader, target, left) => {
|
|
453
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1092', left());
|
|
454
|
+
// 16 bytes, seems to be 4 integers
|
|
455
|
+
target._ir1092 = (0, psdReader_1.readBytes)(reader, left());
|
|
456
|
+
}, (writer, target) => {
|
|
457
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1092);
|
|
458
|
+
});
|
|
459
|
+
// 0 - normal, 7 - multiply, 8 - screen, 23 - difference
|
|
460
|
+
const onionSkinsBlendModes = [
|
|
461
|
+
'normal', undefined, undefined, undefined, undefined, undefined, undefined, 'multiply',
|
|
462
|
+
'screen', undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
|
463
|
+
undefined, undefined, undefined, undefined, undefined, undefined, undefined, 'difference',
|
|
464
|
+
];
|
|
465
|
+
addHandler(1078, // Onion Skins
|
|
466
|
+
// Onion Skins
|
|
467
|
+
target => target.onionSkins !== undefined, (reader, target) => {
|
|
468
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
469
|
+
// console.log('1078', require('util').inspect(desc, false, 99, true));
|
|
470
|
+
target.onionSkins = {
|
|
471
|
+
enabled: desc.enab,
|
|
472
|
+
framesBefore: desc.numBefore,
|
|
473
|
+
framesAfter: desc.numAfter,
|
|
474
|
+
frameSpacing: desc.Spcn,
|
|
475
|
+
minOpacity: desc.minOpacity / 100,
|
|
476
|
+
maxOpacity: desc.maxOpacity / 100,
|
|
477
|
+
blendMode: onionSkinsBlendModes[desc.BlnM] || 'normal',
|
|
478
|
+
};
|
|
479
|
+
}, (writer, target) => {
|
|
480
|
+
const onionSkins = target.onionSkins;
|
|
481
|
+
const desc = {
|
|
482
|
+
Vrsn: 1,
|
|
483
|
+
enab: onionSkins.enabled,
|
|
484
|
+
numBefore: onionSkins.framesBefore,
|
|
485
|
+
numAfter: onionSkins.framesAfter,
|
|
486
|
+
Spcn: onionSkins.frameSpacing,
|
|
487
|
+
minOpacity: (onionSkins.minOpacity * 100) | 0,
|
|
488
|
+
maxOpacity: (onionSkins.maxOpacity * 100) | 0,
|
|
489
|
+
BlnM: Math.max(0, onionSkinsBlendModes.indexOf(onionSkins.blendMode)),
|
|
490
|
+
};
|
|
491
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
|
|
492
|
+
});
|
|
493
|
+
addHandler(1075, // Timeline Information
|
|
494
|
+
// Timeline Information
|
|
495
|
+
target => target.timelineInformation !== undefined, (reader, target) => {
|
|
496
|
+
var _a, _b;
|
|
497
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
498
|
+
target.timelineInformation = {
|
|
499
|
+
enabled: desc.enab,
|
|
500
|
+
frameStep: (0, descriptor_1.frac)(desc.frameStep),
|
|
501
|
+
frameRate: desc.frameRate,
|
|
502
|
+
time: (0, descriptor_1.frac)(desc.time),
|
|
503
|
+
duration: (0, descriptor_1.frac)(desc.duration),
|
|
504
|
+
workInTime: (0, descriptor_1.frac)(desc.workInTime),
|
|
505
|
+
workOutTime: (0, descriptor_1.frac)(desc.workOutTime),
|
|
506
|
+
repeats: desc.LCnt,
|
|
507
|
+
hasMotion: desc.hasMotion,
|
|
508
|
+
globalTracks: (0, descriptor_1.parseTrackList)(desc.globalTrackList, !!reader.logMissingFeatures),
|
|
509
|
+
};
|
|
510
|
+
if ((_b = (_a = desc.audioClipGroupList) === null || _a === void 0 ? void 0 : _a.audioClipGroupList) === null || _b === void 0 ? void 0 : _b.length) {
|
|
511
|
+
target.timelineInformation.audioClipGroups = desc.audioClipGroupList.audioClipGroupList.map(g => ({
|
|
512
|
+
id: g.groupID,
|
|
513
|
+
muted: g.muted,
|
|
514
|
+
audioClips: g.audioClipList.map(({ clipID, timeScope, muted, audioLevel, frameReader }) => ({
|
|
515
|
+
id: clipID,
|
|
516
|
+
start: (0, descriptor_1.frac)(timeScope.Strt),
|
|
517
|
+
duration: (0, descriptor_1.frac)(timeScope.duration),
|
|
518
|
+
inTime: (0, descriptor_1.frac)(timeScope.inTime),
|
|
519
|
+
outTime: (0, descriptor_1.frac)(timeScope.outTime),
|
|
520
|
+
muted: muted,
|
|
521
|
+
audioLevel: audioLevel,
|
|
522
|
+
frameReader: {
|
|
523
|
+
type: frameReader.frameReaderType,
|
|
524
|
+
mediaDescriptor: frameReader.mediaDescriptor,
|
|
525
|
+
link: {
|
|
526
|
+
name: frameReader['Lnk ']['Nm '],
|
|
527
|
+
fullPath: frameReader['Lnk '].fullPath,
|
|
528
|
+
relativePath: frameReader['Lnk '].relPath,
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
})),
|
|
532
|
+
}));
|
|
533
|
+
}
|
|
534
|
+
}, (writer, target) => {
|
|
535
|
+
var _a;
|
|
536
|
+
const timeline = target.timelineInformation;
|
|
537
|
+
const desc = {
|
|
538
|
+
Vrsn: 1,
|
|
539
|
+
enab: timeline.enabled,
|
|
540
|
+
frameStep: timeline.frameStep,
|
|
541
|
+
frameRate: timeline.frameRate,
|
|
542
|
+
time: timeline.time,
|
|
543
|
+
duration: timeline.duration,
|
|
544
|
+
workInTime: timeline.workInTime,
|
|
545
|
+
workOutTime: timeline.workOutTime,
|
|
546
|
+
LCnt: timeline.repeats,
|
|
547
|
+
globalTrackList: (0, descriptor_1.serializeTrackList)(timeline.globalTracks),
|
|
548
|
+
audioClipGroupList: {
|
|
549
|
+
audioClipGroupList: (_a = timeline.audioClipGroups) === null || _a === void 0 ? void 0 : _a.map(a => ({
|
|
550
|
+
groupID: a.id,
|
|
551
|
+
muted: a.muted,
|
|
552
|
+
audioClipList: a.audioClips.map(c => ({
|
|
553
|
+
clipID: c.id,
|
|
554
|
+
timeScope: {
|
|
555
|
+
Vrsn: 1,
|
|
556
|
+
Strt: c.start,
|
|
557
|
+
duration: c.duration,
|
|
558
|
+
inTime: c.inTime,
|
|
559
|
+
outTime: c.outTime,
|
|
560
|
+
},
|
|
561
|
+
frameReader: {
|
|
562
|
+
frameReaderType: c.frameReader.type,
|
|
563
|
+
descVersion: 1,
|
|
564
|
+
'Lnk ': {
|
|
565
|
+
descVersion: 1,
|
|
566
|
+
'Nm ': c.frameReader.link.name,
|
|
567
|
+
fullPath: c.frameReader.link.fullPath,
|
|
568
|
+
relPath: c.frameReader.link.relativePath,
|
|
569
|
+
},
|
|
570
|
+
mediaDescriptor: c.frameReader.mediaDescriptor,
|
|
571
|
+
},
|
|
572
|
+
muted: c.muted,
|
|
573
|
+
audioLevel: c.audioLevel,
|
|
574
|
+
})),
|
|
575
|
+
})),
|
|
576
|
+
},
|
|
577
|
+
hasMotion: timeline.hasMotion,
|
|
578
|
+
};
|
|
579
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc, 'anim');
|
|
580
|
+
});
|
|
581
|
+
addHandler(1076, // Sheet Disclosure
|
|
582
|
+
// Sheet Disclosure
|
|
583
|
+
target => target.sheetDisclosure !== undefined, (reader, target) => {
|
|
584
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
585
|
+
target.sheetDisclosure = {};
|
|
586
|
+
if (desc.sheetTimelineOptions) {
|
|
587
|
+
target.sheetDisclosure.sheetTimelineOptions = desc.sheetTimelineOptions.map(o => ({
|
|
588
|
+
sheetID: o.sheetID,
|
|
589
|
+
sheetDisclosed: o.sheetDisclosed,
|
|
590
|
+
lightsDisclosed: o.lightsDisclosed,
|
|
591
|
+
meshesDisclosed: o.meshesDisclosed,
|
|
592
|
+
materialsDisclosed: o.materialsDisclosed,
|
|
593
|
+
}));
|
|
594
|
+
}
|
|
595
|
+
}, (writer, target) => {
|
|
596
|
+
const disclosure = target.sheetDisclosure;
|
|
597
|
+
const desc = { Vrsn: 1 };
|
|
598
|
+
if (disclosure.sheetTimelineOptions) {
|
|
599
|
+
desc.sheetTimelineOptions = disclosure.sheetTimelineOptions.map(d => ({
|
|
600
|
+
Vrsn: 2,
|
|
601
|
+
sheetID: d.sheetID,
|
|
602
|
+
sheetDisclosed: d.sheetDisclosed,
|
|
603
|
+
lightsDisclosed: d.lightsDisclosed,
|
|
604
|
+
meshesDisclosed: d.meshesDisclosed,
|
|
605
|
+
materialsDisclosed: d.materialsDisclosed,
|
|
606
|
+
}));
|
|
607
|
+
}
|
|
608
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
|
|
609
|
+
});
|
|
610
|
+
addHandler(1054, // URL List
|
|
611
|
+
// URL List
|
|
612
|
+
target => target.urlsList !== undefined, (reader, target) => {
|
|
613
|
+
const count = (0, psdReader_1.readUint32)(reader);
|
|
614
|
+
target.urlsList = [];
|
|
615
|
+
for (let i = 0; i < count; i++) {
|
|
616
|
+
const long = (0, psdReader_1.readSignature)(reader);
|
|
617
|
+
if (long !== 'slic' && reader.throwForMissingFeatures)
|
|
618
|
+
throw new Error('Unknown long');
|
|
619
|
+
const id = (0, psdReader_1.readUint32)(reader);
|
|
620
|
+
const url = (0, psdReader_1.readUnicodeString)(reader);
|
|
621
|
+
target.urlsList.push({ id, url, ref: 'slice' });
|
|
622
|
+
}
|
|
623
|
+
}, (writer, target) => {
|
|
624
|
+
const list = target.urlsList;
|
|
625
|
+
(0, psdWriter_1.writeUint32)(writer, list.length);
|
|
626
|
+
for (let i = 0; i < list.length; i++) {
|
|
627
|
+
(0, psdWriter_1.writeSignature)(writer, 'slic');
|
|
628
|
+
(0, psdWriter_1.writeUint32)(writer, list[i].id);
|
|
629
|
+
(0, psdWriter_1.writeUnicodeString)(writer, list[i].url);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
function boundsToBounds(bounds) {
|
|
633
|
+
return { 'Top ': bounds.top, Left: bounds.left, Btom: bounds.bottom, Rght: bounds.right };
|
|
634
|
+
}
|
|
635
|
+
function boundsFromBounds(bounds) {
|
|
636
|
+
return { top: bounds['Top '], left: bounds.Left, bottom: bounds.Btom, right: bounds.Rght };
|
|
637
|
+
}
|
|
638
|
+
function clamped(array, index) {
|
|
639
|
+
return array[Math.max(0, Math.min(array.length - 1, index))];
|
|
640
|
+
}
|
|
641
|
+
const sliceOrigins = ['autoGenerated', 'layer', 'userGenerated'];
|
|
642
|
+
const sliceTypes = ['noImage', 'image'];
|
|
643
|
+
const sliceAlignments = ['default'];
|
|
644
|
+
addHandler(1050, // Slices
|
|
645
|
+
// Slices
|
|
646
|
+
target => target.slices ? target.slices.length : 0, (reader, target) => {
|
|
647
|
+
const version = (0, psdReader_1.readUint32)(reader);
|
|
648
|
+
if (version === 6) {
|
|
649
|
+
if (!target.slices)
|
|
650
|
+
target.slices = [];
|
|
651
|
+
const top = (0, psdReader_1.readInt32)(reader);
|
|
652
|
+
const left = (0, psdReader_1.readInt32)(reader);
|
|
653
|
+
const bottom = (0, psdReader_1.readInt32)(reader);
|
|
654
|
+
const right = (0, psdReader_1.readInt32)(reader);
|
|
655
|
+
const groupName = (0, psdReader_1.readUnicodeString)(reader);
|
|
656
|
+
const count = (0, psdReader_1.readUint32)(reader);
|
|
657
|
+
target.slices.push({ bounds: { top, left, bottom, right }, groupName, slices: [] });
|
|
658
|
+
const slices = target.slices[target.slices.length - 1].slices;
|
|
659
|
+
for (let i = 0; i < count; i++) {
|
|
660
|
+
const id = (0, psdReader_1.readUint32)(reader);
|
|
661
|
+
const groupId = (0, psdReader_1.readUint32)(reader);
|
|
662
|
+
const origin = clamped(sliceOrigins, (0, psdReader_1.readUint32)(reader));
|
|
663
|
+
const associatedLayerId = origin == 'layer' ? (0, psdReader_1.readUint32)(reader) : 0;
|
|
664
|
+
const name = (0, psdReader_1.readUnicodeString)(reader);
|
|
665
|
+
const type = clamped(sliceTypes, (0, psdReader_1.readUint32)(reader));
|
|
666
|
+
const left = (0, psdReader_1.readInt32)(reader);
|
|
667
|
+
const top = (0, psdReader_1.readInt32)(reader);
|
|
668
|
+
const right = (0, psdReader_1.readInt32)(reader);
|
|
669
|
+
const bottom = (0, psdReader_1.readInt32)(reader);
|
|
670
|
+
const url = (0, psdReader_1.readUnicodeString)(reader);
|
|
671
|
+
const target = (0, psdReader_1.readUnicodeString)(reader);
|
|
672
|
+
const message = (0, psdReader_1.readUnicodeString)(reader);
|
|
673
|
+
const altTag = (0, psdReader_1.readUnicodeString)(reader);
|
|
674
|
+
const cellTextIsHTML = !!(0, psdReader_1.readUint8)(reader);
|
|
675
|
+
const cellText = (0, psdReader_1.readUnicodeString)(reader);
|
|
676
|
+
const horizontalAlignment = clamped(sliceAlignments, (0, psdReader_1.readUint32)(reader));
|
|
677
|
+
const verticalAlignment = clamped(sliceAlignments, (0, psdReader_1.readUint32)(reader));
|
|
678
|
+
const a = (0, psdReader_1.readUint8)(reader);
|
|
679
|
+
const r = (0, psdReader_1.readUint8)(reader);
|
|
680
|
+
const g = (0, psdReader_1.readUint8)(reader);
|
|
681
|
+
const b = (0, psdReader_1.readUint8)(reader);
|
|
682
|
+
const backgroundColorType = ((a + r + g + b) === 0) ? 'none' : (a === 0 ? 'matte' : 'color');
|
|
683
|
+
slices.push({
|
|
684
|
+
id, groupId, origin, associatedLayerId, name, target, message, altTag, cellTextIsHTML, cellText,
|
|
685
|
+
horizontalAlignment, verticalAlignment, type, url,
|
|
686
|
+
bounds: { top, left, bottom, right },
|
|
687
|
+
backgroundColorType, backgroundColor: { r, g, b, a },
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
691
|
+
desc.slices.forEach(d => {
|
|
692
|
+
const slice = slices.find(s => d.sliceID == s.id);
|
|
693
|
+
if (slice) {
|
|
694
|
+
slice.topOutset = d.topOutset;
|
|
695
|
+
slice.leftOutset = d.leftOutset;
|
|
696
|
+
slice.bottomOutset = d.bottomOutset;
|
|
697
|
+
slice.rightOutset = d.rightOutset;
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
else if (version === 7 || version === 8) {
|
|
702
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
703
|
+
if (!target.slices)
|
|
704
|
+
target.slices = [];
|
|
705
|
+
target.slices.push({
|
|
706
|
+
groupName: desc.baseName,
|
|
707
|
+
bounds: boundsFromBounds(desc.bounds),
|
|
708
|
+
slices: desc.slices.map(s => (Object.assign(Object.assign({}, (s['Nm '] ? { name: s['Nm '] } : {})), { id: s.sliceID, groupId: s.groupID, associatedLayerId: 0, origin: descriptor_1.ESliceOrigin.decode(s.origin), type: descriptor_1.ESliceType.decode(s.Type), bounds: boundsFromBounds(s.bounds), url: s.url, target: s.null, message: s.Msge, altTag: s.altTag, cellTextIsHTML: s.cellTextIsHTML, cellText: s.cellText, horizontalAlignment: descriptor_1.ESliceHorzAlign.decode(s.horzAlign), verticalAlignment: descriptor_1.ESliceVertAlign.decode(s.vertAlign), backgroundColorType: descriptor_1.ESliceBGColorType.decode(s.bgColorType), backgroundColor: s.bgColor ? { r: s.bgColor['Rd '], g: s.bgColor['Grn '], b: s.bgColor['Bl '], a: s.bgColor.alpha } : { r: 0, g: 0, b: 0, a: 0 }, topOutset: s.topOutset || 0, leftOutset: s.leftOutset || 0, bottomOutset: s.bottomOutset || 0, rightOutset: s.rightOutset || 0 }))),
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
else {
|
|
712
|
+
throw new Error(`Invalid slices version (${version})`);
|
|
713
|
+
}
|
|
714
|
+
}, (writer, target, index) => {
|
|
715
|
+
const { bounds, groupName, slices } = target.slices[index];
|
|
716
|
+
(0, psdWriter_1.writeUint32)(writer, 6); // version
|
|
717
|
+
(0, psdWriter_1.writeInt32)(writer, bounds.top);
|
|
718
|
+
(0, psdWriter_1.writeInt32)(writer, bounds.left);
|
|
719
|
+
(0, psdWriter_1.writeInt32)(writer, bounds.bottom);
|
|
720
|
+
(0, psdWriter_1.writeInt32)(writer, bounds.right);
|
|
721
|
+
(0, psdWriter_1.writeUnicodeString)(writer, groupName);
|
|
722
|
+
(0, psdWriter_1.writeUint32)(writer, slices.length);
|
|
723
|
+
for (let i = 0; i < slices.length; i++) {
|
|
724
|
+
const slice = slices[i];
|
|
725
|
+
let { a, r, g, b } = slice.backgroundColor;
|
|
726
|
+
if (slice.backgroundColorType === 'none') {
|
|
727
|
+
a = r = g = b = 0;
|
|
728
|
+
}
|
|
729
|
+
else if (slice.backgroundColorType === 'matte') {
|
|
730
|
+
a = 0;
|
|
731
|
+
r = g = b = 255;
|
|
732
|
+
}
|
|
733
|
+
(0, psdWriter_1.writeUint32)(writer, slice.id);
|
|
734
|
+
(0, psdWriter_1.writeUint32)(writer, slice.groupId);
|
|
735
|
+
(0, psdWriter_1.writeUint32)(writer, sliceOrigins.indexOf(slice.origin));
|
|
736
|
+
if (slice.origin === 'layer')
|
|
737
|
+
(0, psdWriter_1.writeUint32)(writer, slice.associatedLayerId);
|
|
738
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.name || '');
|
|
739
|
+
(0, psdWriter_1.writeUint32)(writer, sliceTypes.indexOf(slice.type));
|
|
740
|
+
(0, psdWriter_1.writeInt32)(writer, slice.bounds.left);
|
|
741
|
+
(0, psdWriter_1.writeInt32)(writer, slice.bounds.top);
|
|
742
|
+
(0, psdWriter_1.writeInt32)(writer, slice.bounds.right);
|
|
743
|
+
(0, psdWriter_1.writeInt32)(writer, slice.bounds.bottom);
|
|
744
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.url);
|
|
745
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.target);
|
|
746
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.message);
|
|
747
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.altTag);
|
|
748
|
+
(0, psdWriter_1.writeUint8)(writer, slice.cellTextIsHTML ? 1 : 0);
|
|
749
|
+
(0, psdWriter_1.writeUnicodeString)(writer, slice.cellText);
|
|
750
|
+
(0, psdWriter_1.writeUint32)(writer, sliceAlignments.indexOf(slice.horizontalAlignment));
|
|
751
|
+
(0, psdWriter_1.writeUint32)(writer, sliceAlignments.indexOf(slice.verticalAlignment));
|
|
752
|
+
(0, psdWriter_1.writeUint8)(writer, a);
|
|
753
|
+
(0, psdWriter_1.writeUint8)(writer, r);
|
|
754
|
+
(0, psdWriter_1.writeUint8)(writer, g);
|
|
755
|
+
(0, psdWriter_1.writeUint8)(writer, b);
|
|
756
|
+
}
|
|
757
|
+
const desc = {
|
|
758
|
+
bounds: boundsToBounds(bounds),
|
|
759
|
+
slices: [],
|
|
760
|
+
};
|
|
761
|
+
slices.forEach(s => {
|
|
762
|
+
const slice = Object.assign(Object.assign({ sliceID: s.id, groupID: s.groupId, origin: descriptor_1.ESliceOrigin.encode(s.origin), Type: descriptor_1.ESliceType.encode(s.type), bounds: boundsToBounds(s.bounds) }, (s.name ? { 'Nm ': s.name } : {})), { url: s.url, null: s.target, Msge: s.message, altTag: s.altTag, cellTextIsHTML: s.cellTextIsHTML, cellText: s.cellText, horzAlign: descriptor_1.ESliceHorzAlign.encode(s.horizontalAlignment), vertAlign: descriptor_1.ESliceVertAlign.encode(s.verticalAlignment), bgColorType: descriptor_1.ESliceBGColorType.encode(s.backgroundColorType) });
|
|
763
|
+
if (s.backgroundColorType === 'color') {
|
|
764
|
+
const { r, g, b, a } = s.backgroundColor;
|
|
765
|
+
slice.bgColor = { 'Rd ': r, 'Grn ': g, 'Bl ': b, alpha: a };
|
|
766
|
+
}
|
|
767
|
+
slice.topOutset = s.topOutset || 0;
|
|
768
|
+
slice.leftOutset = s.leftOutset || 0;
|
|
769
|
+
slice.bottomOutset = s.bottomOutset || 0;
|
|
770
|
+
slice.rightOutset = s.rightOutset || 0;
|
|
771
|
+
desc.slices.push(slice);
|
|
772
|
+
});
|
|
773
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc, 'slices');
|
|
774
|
+
});
|
|
775
|
+
addHandler(1064, target => target.pixelAspectRatio !== undefined, (reader, target) => {
|
|
776
|
+
if ((0, psdReader_1.readUint32)(reader) > 2)
|
|
777
|
+
throw new Error('Invalid pixelAspectRatio version');
|
|
778
|
+
target.pixelAspectRatio = { aspect: (0, psdReader_1.readFloat64)(reader) };
|
|
779
|
+
}, (writer, target) => {
|
|
780
|
+
(0, psdWriter_1.writeUint32)(writer, 2); // version
|
|
781
|
+
(0, psdWriter_1.writeFloat64)(writer, target.pixelAspectRatio.aspect);
|
|
782
|
+
});
|
|
783
|
+
addHandler(1041, target => target.iccUntaggedProfile !== undefined, (reader, target) => {
|
|
784
|
+
target.iccUntaggedProfile = !!(0, psdReader_1.readUint8)(reader);
|
|
785
|
+
}, (writer, target) => {
|
|
786
|
+
(0, psdWriter_1.writeUint8)(writer, target.iccUntaggedProfile ? 1 : 0);
|
|
787
|
+
});
|
|
788
|
+
helpers_1.MOCK_HANDLERS && addHandler(1039, // ICC Profile
|
|
789
|
+
// ICC Profile
|
|
790
|
+
target => target._ir1039 !== undefined, (reader, target, left) => {
|
|
791
|
+
// TODO: this is raw bytes, just return as a byte array
|
|
792
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1039', left());
|
|
793
|
+
target._ir1039 = (0, psdReader_1.readBytes)(reader, left());
|
|
794
|
+
}, (writer, target) => {
|
|
795
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1039);
|
|
796
|
+
});
|
|
797
|
+
addHandler(1044, target => target.idsSeedNumber !== undefined, (reader, target) => target.idsSeedNumber = (0, psdReader_1.readUint32)(reader), (writer, target) => (0, psdWriter_1.writeUint32)(writer, target.idsSeedNumber));
|
|
798
|
+
addHandler(1036, target => target.thumbnail !== undefined || target.thumbnailRaw !== undefined, (reader, target, left) => {
|
|
799
|
+
const format = (0, psdReader_1.readUint32)(reader); // 1 = kJpegRGB, 0 = kRawRGB
|
|
800
|
+
const width = (0, psdReader_1.readUint32)(reader);
|
|
801
|
+
const height = (0, psdReader_1.readUint32)(reader);
|
|
802
|
+
(0, psdReader_1.readUint32)(reader); // widthBytes = (width * bits_per_pixel + 31) / 32 * 4.
|
|
803
|
+
(0, psdReader_1.readUint32)(reader); // totalSize = widthBytes * height * planes
|
|
804
|
+
(0, psdReader_1.readUint32)(reader); // sizeAfterCompression
|
|
805
|
+
const bitsPerPixel = (0, psdReader_1.readUint16)(reader); // 24
|
|
806
|
+
const planes = (0, psdReader_1.readUint16)(reader); // 1
|
|
807
|
+
if (format !== 1 || bitsPerPixel !== 24 || planes !== 1) {
|
|
808
|
+
reader.logMissingFeatures && reader.log(`Invalid thumbnail data (format: ${format}, bitsPerPixel: ${bitsPerPixel}, planes: ${planes})`);
|
|
809
|
+
(0, psdReader_1.skipBytes)(reader, left());
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
const size = left();
|
|
813
|
+
const data = (0, psdReader_1.readBytes)(reader, size);
|
|
814
|
+
if (reader.useRawThumbnail) {
|
|
815
|
+
target.thumbnailRaw = { width, height, data };
|
|
816
|
+
}
|
|
817
|
+
else if (data.byteLength) {
|
|
818
|
+
target.thumbnail = (0, helpers_1.createCanvasFromData)(data);
|
|
819
|
+
}
|
|
820
|
+
}, (writer, target) => {
|
|
821
|
+
var _a;
|
|
822
|
+
let width = 0;
|
|
823
|
+
let height = 0;
|
|
824
|
+
let data = new Uint8Array(0);
|
|
825
|
+
if (target.thumbnailRaw) {
|
|
826
|
+
width = target.thumbnailRaw.width;
|
|
827
|
+
height = target.thumbnailRaw.height;
|
|
828
|
+
data = target.thumbnailRaw.data;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
try {
|
|
832
|
+
const dataUrl = (_a = target.thumbnail.toDataURL('image/jpeg', 1)) === null || _a === void 0 ? void 0 : _a.substring('data:image/jpeg;base64,'.length);
|
|
833
|
+
if (dataUrl) {
|
|
834
|
+
data = (0, base64_js_1.toByteArray)(dataUrl); // this sometimes fails for some reason, maybe some browser bugs
|
|
835
|
+
width = target.thumbnail.width;
|
|
836
|
+
height = target.thumbnail.height;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
catch (_b) { }
|
|
840
|
+
}
|
|
841
|
+
const bitsPerPixel = 24;
|
|
842
|
+
const widthBytes = Math.floor((width * bitsPerPixel + 31) / 32) * 4;
|
|
843
|
+
const planes = 1;
|
|
844
|
+
const totalSize = widthBytes * height * planes;
|
|
845
|
+
const sizeAfterCompression = data.length;
|
|
846
|
+
(0, psdWriter_1.writeUint32)(writer, 1); // 1 = kJpegRGB
|
|
847
|
+
(0, psdWriter_1.writeUint32)(writer, width);
|
|
848
|
+
(0, psdWriter_1.writeUint32)(writer, height);
|
|
849
|
+
(0, psdWriter_1.writeUint32)(writer, widthBytes);
|
|
850
|
+
(0, psdWriter_1.writeUint32)(writer, totalSize);
|
|
851
|
+
(0, psdWriter_1.writeUint32)(writer, sizeAfterCompression);
|
|
852
|
+
(0, psdWriter_1.writeUint16)(writer, bitsPerPixel);
|
|
853
|
+
(0, psdWriter_1.writeUint16)(writer, planes);
|
|
854
|
+
(0, psdWriter_1.writeBytes)(writer, data);
|
|
855
|
+
});
|
|
856
|
+
addHandler(1057, target => target.versionInfo !== undefined, (reader, target, left) => {
|
|
857
|
+
const version = (0, psdReader_1.readUint32)(reader);
|
|
858
|
+
if (version !== 1)
|
|
859
|
+
throw new Error('Invalid versionInfo version');
|
|
860
|
+
target.versionInfo = {
|
|
861
|
+
hasRealMergedData: !!(0, psdReader_1.readUint8)(reader),
|
|
862
|
+
writerName: (0, psdReader_1.readUnicodeString)(reader),
|
|
863
|
+
readerName: (0, psdReader_1.readUnicodeString)(reader),
|
|
864
|
+
fileVersion: (0, psdReader_1.readUint32)(reader),
|
|
865
|
+
};
|
|
866
|
+
(0, psdReader_1.skipBytes)(reader, left());
|
|
867
|
+
}, (writer, target) => {
|
|
868
|
+
const versionInfo = target.versionInfo;
|
|
869
|
+
(0, psdWriter_1.writeUint32)(writer, 1); // version
|
|
870
|
+
(0, psdWriter_1.writeUint8)(writer, versionInfo.hasRealMergedData ? 1 : 0);
|
|
871
|
+
(0, psdWriter_1.writeUnicodeString)(writer, versionInfo.writerName);
|
|
872
|
+
(0, psdWriter_1.writeUnicodeString)(writer, versionInfo.readerName);
|
|
873
|
+
(0, psdWriter_1.writeUint32)(writer, versionInfo.fileVersion);
|
|
874
|
+
});
|
|
875
|
+
helpers_1.MOCK_HANDLERS && addHandler(1058, // EXIF data 1.
|
|
876
|
+
// EXIF data 1.
|
|
877
|
+
target => target._ir1058 !== undefined, (reader, target, left) => {
|
|
878
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1058', left());
|
|
879
|
+
target._ir1058 = (0, psdReader_1.readBytes)(reader, left());
|
|
880
|
+
}, (writer, target) => {
|
|
881
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1058);
|
|
882
|
+
});
|
|
883
|
+
addHandler(7000, target => target.imageReadyVariables !== undefined, (reader, target, left) => {
|
|
884
|
+
target.imageReadyVariables = readUtf8String(reader, left());
|
|
885
|
+
}, (writer, target) => {
|
|
886
|
+
writeUtf8String(writer, target.imageReadyVariables);
|
|
887
|
+
});
|
|
888
|
+
addHandler(7001, target => target.imageReadyDataSets !== undefined, (reader, target, left) => {
|
|
889
|
+
target.imageReadyDataSets = readUtf8String(reader, left());
|
|
890
|
+
}, (writer, target) => {
|
|
891
|
+
writeUtf8String(writer, target.imageReadyDataSets);
|
|
892
|
+
});
|
|
893
|
+
addHandler(1088, target => target.pathSelectionState !== undefined, (reader, target, _left) => {
|
|
894
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
895
|
+
target.pathSelectionState = desc['null'];
|
|
896
|
+
}, (writer, target) => {
|
|
897
|
+
const desc = { 'null': target.pathSelectionState };
|
|
898
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
|
|
899
|
+
});
|
|
900
|
+
helpers_1.MOCK_HANDLERS && addHandler(1025, target => target._ir1025 !== undefined, (reader, target, left) => {
|
|
901
|
+
LOG_MOCK_HANDLERS && console.log('image resource 1025', left());
|
|
902
|
+
target._ir1025 = (0, psdReader_1.readBytes)(reader, left());
|
|
903
|
+
}, (writer, target) => {
|
|
904
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir1025);
|
|
905
|
+
});
|
|
906
|
+
const FrmD = (0, helpers_1.createEnum)('FrmD', '', {
|
|
907
|
+
auto: 'Auto',
|
|
908
|
+
none: 'None',
|
|
909
|
+
dispose: 'Disp',
|
|
910
|
+
});
|
|
911
|
+
addHandler(4000, // Plug-In resource(s)
|
|
912
|
+
// Plug-In resource(s)
|
|
913
|
+
target => target.animations !== undefined, (reader, target, left) => {
|
|
914
|
+
const key = (0, psdReader_1.readSignature)(reader);
|
|
915
|
+
if (key === 'mani') {
|
|
916
|
+
(0, psdReader_1.checkSignature)(reader, 'IRFR');
|
|
917
|
+
(0, psdReader_1.readSection)(reader, 1, left => {
|
|
918
|
+
while (left() > 0) {
|
|
919
|
+
(0, psdReader_1.checkSignature)(reader, '8BIM');
|
|
920
|
+
const key = (0, psdReader_1.readSignature)(reader);
|
|
921
|
+
(0, psdReader_1.readSection)(reader, 1, left => {
|
|
922
|
+
if (key === 'AnDs') {
|
|
923
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
924
|
+
target.animations = {
|
|
925
|
+
// desc.AFSt ???
|
|
926
|
+
frames: desc.FrIn.map(x => ({
|
|
927
|
+
id: x.FrID,
|
|
928
|
+
delay: (x.FrDl || 0) / 100,
|
|
929
|
+
dispose: x.FrDs ? FrmD.decode(x.FrDs) : 'auto', // missing == auto
|
|
930
|
+
// x.FrGA ???
|
|
931
|
+
})),
|
|
932
|
+
animations: desc.FSts.map(x => ({
|
|
933
|
+
id: x.FsID,
|
|
934
|
+
frames: x.FsFr,
|
|
935
|
+
repeats: x.LCnt,
|
|
936
|
+
activeFrame: x.AFrm || 0,
|
|
937
|
+
})),
|
|
938
|
+
};
|
|
939
|
+
// console.log('#4000 AnDs', require('util').inspect(desc, false, 99, true));
|
|
940
|
+
// console.log('#4000 AnDs:result', require('util').inspect(target.animations, false, 99, true));
|
|
941
|
+
}
|
|
942
|
+
else if (key === 'Roll') {
|
|
943
|
+
const bytes = (0, psdReader_1.readBytes)(reader, left());
|
|
944
|
+
reader.logDevFeatures && reader.log('#4000 Roll', bytes);
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
reader.logMissingFeatures && reader.log('Unhandled subsection in #4000', key);
|
|
948
|
+
}
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
else if (key === 'mopt') {
|
|
954
|
+
const bytes = (0, psdReader_1.readBytes)(reader, left());
|
|
955
|
+
reader.logDevFeatures && reader.log('#4000 mopt', bytes);
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
reader.logMissingFeatures && reader.log('Unhandled key in #4000:', key);
|
|
959
|
+
}
|
|
960
|
+
}, (writer, target) => {
|
|
961
|
+
if (target.animations) {
|
|
962
|
+
(0, psdWriter_1.writeSignature)(writer, 'mani');
|
|
963
|
+
(0, psdWriter_1.writeSignature)(writer, 'IRFR');
|
|
964
|
+
(0, psdWriter_1.writeSection)(writer, 1, () => {
|
|
965
|
+
(0, psdWriter_1.writeSignature)(writer, '8BIM');
|
|
966
|
+
(0, psdWriter_1.writeSignature)(writer, 'AnDs');
|
|
967
|
+
(0, psdWriter_1.writeSection)(writer, 1, () => {
|
|
968
|
+
const desc = {
|
|
969
|
+
// AFSt: 0, // ???
|
|
970
|
+
FrIn: [],
|
|
971
|
+
FSts: [],
|
|
972
|
+
};
|
|
973
|
+
for (let i = 0; i < target.animations.frames.length; i++) {
|
|
974
|
+
const f = target.animations.frames[i];
|
|
975
|
+
const frame = {
|
|
976
|
+
FrID: f.id,
|
|
977
|
+
};
|
|
978
|
+
if (f.delay)
|
|
979
|
+
frame.FrDl = (f.delay * 100) | 0;
|
|
980
|
+
frame.FrDs = FrmD.encode(f.dispose);
|
|
981
|
+
// if (i === 0) frame.FrGA = 30; // ???
|
|
982
|
+
desc.FrIn.push(frame);
|
|
983
|
+
}
|
|
984
|
+
for (let i = 0; i < target.animations.animations.length; i++) {
|
|
985
|
+
const a = target.animations.animations[i];
|
|
986
|
+
const anim = {
|
|
987
|
+
FsID: a.id,
|
|
988
|
+
AFrm: a.activeFrame | 0,
|
|
989
|
+
FsFr: a.frames,
|
|
990
|
+
LCnt: a.repeats | 0,
|
|
991
|
+
};
|
|
992
|
+
desc.FSts.push(anim);
|
|
993
|
+
}
|
|
994
|
+
(0, descriptor_1.writeVersionAndDescriptor)(writer, '', 'null', desc);
|
|
995
|
+
});
|
|
996
|
+
// writeSignature(writer, '8BIM');
|
|
997
|
+
// writeSignature(writer, 'Roll');
|
|
998
|
+
// writeSection(writer, 1, () => {
|
|
999
|
+
// writeZeros(writer, 8);
|
|
1000
|
+
// });
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
// TODO: Unfinished
|
|
1005
|
+
helpers_1.MOCK_HANDLERS && addHandler(4001, // Plug-In resource(s)
|
|
1006
|
+
// Plug-In resource(s)
|
|
1007
|
+
target => target._ir4001 !== undefined, (reader, target, left) => {
|
|
1008
|
+
if (helpers_1.MOCK_HANDLERS) {
|
|
1009
|
+
LOG_MOCK_HANDLERS && console.log('image resource 4001', left());
|
|
1010
|
+
target._ir4001 = (0, psdReader_1.readBytes)(reader, left());
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const key = (0, psdReader_1.readSignature)(reader);
|
|
1014
|
+
if (key === 'mfri') {
|
|
1015
|
+
const version = (0, psdReader_1.readUint32)(reader);
|
|
1016
|
+
if (version !== 2)
|
|
1017
|
+
throw new Error('Invalid mfri version');
|
|
1018
|
+
const length = (0, psdReader_1.readUint32)(reader);
|
|
1019
|
+
const bytes = (0, psdReader_1.readBytes)(reader, length);
|
|
1020
|
+
reader.logDevFeatures && reader.log('mfri', bytes);
|
|
1021
|
+
}
|
|
1022
|
+
else if (key === 'mset') {
|
|
1023
|
+
const desc = (0, descriptor_1.readVersionAndDescriptor)(reader);
|
|
1024
|
+
reader.logDevFeatures && reader.log('mset', desc);
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
reader.logMissingFeatures && reader.log('Unhandled key in #4001', key);
|
|
1028
|
+
}
|
|
1029
|
+
}, (writer, target) => {
|
|
1030
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir4001);
|
|
1031
|
+
});
|
|
1032
|
+
// TODO: Unfinished
|
|
1033
|
+
helpers_1.MOCK_HANDLERS && addHandler(4002, // Plug-In resource(s)
|
|
1034
|
+
// Plug-In resource(s)
|
|
1035
|
+
target => target._ir4002 !== undefined, (reader, target, left) => {
|
|
1036
|
+
LOG_MOCK_HANDLERS && console.log('image resource 4002', left());
|
|
1037
|
+
target._ir4002 = (0, psdReader_1.readBytes)(reader, left());
|
|
1038
|
+
}, (writer, target) => {
|
|
1039
|
+
(0, psdWriter_1.writeBytes)(writer, target._ir4002);
|
|
1040
|
+
});
|
|
1038
1041
|
//# sourceMappingURL=imageResources.js.map
|