ag-psd 31.0.3 → 33.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.
Files changed (159) hide show
  1. package/.v8-cache/v24.7.0-x64-ef5a0af0/00d0e0b4 +0 -0
  2. package/.v8-cache/v24.7.0-x64-ef5a0af0/03e19709 +0 -0
  3. package/.v8-cache/v24.7.0-x64-ef5a0af0/05135617 +0 -0
  4. package/.v8-cache/v24.7.0-x64-ef5a0af0/0cc76730 +0 -0
  5. package/.v8-cache/v24.7.0-x64-ef5a0af0/1130885f +0 -0
  6. package/.v8-cache/v24.7.0-x64-ef5a0af0/20729831 +0 -0
  7. package/.v8-cache/v24.7.0-x64-ef5a0af0/214a593b +0 -0
  8. package/.v8-cache/v24.7.0-x64-ef5a0af0/226e2801 +0 -0
  9. package/.v8-cache/v24.7.0-x64-ef5a0af0/25f8b84a +0 -0
  10. package/.v8-cache/v24.7.0-x64-ef5a0af0/27518289 +0 -0
  11. package/.v8-cache/v24.7.0-x64-ef5a0af0/2a19133e +0 -0
  12. package/.v8-cache/v24.7.0-x64-ef5a0af0/330ef2d9 +0 -0
  13. package/.v8-cache/v24.7.0-x64-ef5a0af0/37ff16b8 +0 -0
  14. package/.v8-cache/v24.7.0-x64-ef5a0af0/3f72a97c +0 -0
  15. package/.v8-cache/v24.7.0-x64-ef5a0af0/4511bacf +0 -0
  16. package/.v8-cache/v24.7.0-x64-ef5a0af0/68416cb2 +0 -0
  17. package/.v8-cache/v24.7.0-x64-ef5a0af0/71df9cb3 +0 -0
  18. package/.v8-cache/v24.7.0-x64-ef5a0af0/75efccd4 +0 -0
  19. package/.v8-cache/v24.7.0-x64-ef5a0af0/762f9305 +0 -0
  20. package/.v8-cache/v24.7.0-x64-ef5a0af0/7bcfc50a +0 -0
  21. package/.v8-cache/v24.7.0-x64-ef5a0af0/7ea06cea +0 -0
  22. package/.v8-cache/v24.7.0-x64-ef5a0af0/825e9a05 +0 -0
  23. package/.v8-cache/v24.7.0-x64-ef5a0af0/87372817 +0 -0
  24. package/.v8-cache/v24.7.0-x64-ef5a0af0/87cf2209 +0 -0
  25. package/.v8-cache/v24.7.0-x64-ef5a0af0/891a7c73 +0 -0
  26. package/.v8-cache/v24.7.0-x64-ef5a0af0/8b68a3a2 +0 -0
  27. package/.v8-cache/v24.7.0-x64-ef5a0af0/932f0770 +0 -0
  28. package/.v8-cache/v24.7.0-x64-ef5a0af0/a1d12a93 +0 -0
  29. package/.v8-cache/v24.7.0-x64-ef5a0af0/a7e80865 +0 -0
  30. package/.v8-cache/v24.7.0-x64-ef5a0af0/ac317c9c +0 -0
  31. package/.v8-cache/v24.7.0-x64-ef5a0af0/acc36e66 +0 -0
  32. package/.v8-cache/v24.7.0-x64-ef5a0af0/b3c2fab7 +0 -0
  33. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8569d6b +0 -0
  34. package/.v8-cache/v24.7.0-x64-ef5a0af0/b8b073c4 +0 -0
  35. package/.v8-cache/v24.7.0-x64-ef5a0af0/bb489c89 +0 -0
  36. package/.v8-cache/v24.7.0-x64-ef5a0af0/c0b789d2 +0 -0
  37. package/.v8-cache/v24.7.0-x64-ef5a0af0/c314aece +0 -0
  38. package/.v8-cache/v24.7.0-x64-ef5a0af0/c46725e1 +0 -0
  39. package/.v8-cache/v24.7.0-x64-ef5a0af0/c794cb34 +0 -0
  40. package/.v8-cache/v24.7.0-x64-ef5a0af0/cd4ae980 +0 -0
  41. package/.v8-cache/v24.7.0-x64-ef5a0af0/cfc49f4f +0 -0
  42. package/.v8-cache/v24.7.0-x64-ef5a0af0/cff9434a +0 -0
  43. package/.v8-cache/v24.7.0-x64-ef5a0af0/d02dd6f7 +0 -0
  44. package/.v8-cache/v24.7.0-x64-ef5a0af0/dc86f000 +0 -0
  45. package/.v8-cache/v24.7.0-x64-ef5a0af0/e03e2acd +0 -0
  46. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6735171 +0 -0
  47. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6745c2b +0 -0
  48. package/.v8-cache/v24.7.0-x64-ef5a0af0/e6b99945 +0 -0
  49. package/.v8-cache/v24.7.0-x64-ef5a0af0/eeeebdfe +0 -0
  50. package/.v8-cache/v24.7.0-x64-ef5a0af0/f5417276 +0 -0
  51. package/.v8-cache/v24.7.0-x64-ef5a0af0/f6fd8125 +0 -0
  52. package/.v8-cache/v24.7.0-x64-ef5a0af0/f74d3518 +0 -0
  53. package/.v8-cache/v24.7.0-x64-ef5a0af0/f886deac +0 -0
  54. package/.v8-cache/v24.7.0-x64-ef5a0af0/fd0a2987 +0 -0
  55. package/.v8-cache/v24.7.0-x64-ef5a0af0/fe349423 +0 -0
  56. package/CHANGELOG.md +107 -0
  57. package/LICENSE +5 -0
  58. package/README.md +3 -6
  59. package/README_PSD.md +242 -81
  60. package/dist/abr.d.ts +11 -4
  61. package/dist/abr.js +363 -229
  62. package/dist/abr.js.map +1 -1
  63. package/dist/additionalInfo.d.ts +56 -2
  64. package/dist/additionalInfo.js +600 -364
  65. package/dist/additionalInfo.js.map +1 -1
  66. package/dist/ase.d.ts +6 -1
  67. package/dist/ase.js +61 -61
  68. package/dist/ase.js.map +1 -1
  69. package/dist/bundle.js +3096 -1541
  70. package/dist/descriptor.d.ts +25 -6
  71. package/dist/descriptor.js +380 -135
  72. package/dist/descriptor.js.map +1 -1
  73. package/dist/effectsHelpers.js +12 -12
  74. package/dist/effectsHelpers.js.map +1 -1
  75. package/dist/engineData.d.ts +3 -1
  76. package/dist/engineData.js +34 -13
  77. package/dist/engineData.js.map +1 -1
  78. package/dist/engineData2.js +50 -21
  79. package/dist/engineData2.js.map +1 -1
  80. package/dist/helpers.d.ts +6 -3
  81. package/dist/helpers.js +22 -6
  82. package/dist/helpers.js.map +1 -1
  83. package/dist/imageResources.d.ts +15 -3
  84. package/dist/imageResources.js +529 -144
  85. package/dist/imageResources.js.map +1 -1
  86. package/dist/index.js +1 -0
  87. package/dist/index.js.map +1 -1
  88. package/dist/jpeg.js +30 -10
  89. package/dist/jpeg.js.map +1 -1
  90. package/dist/psd.d.ts +154 -18
  91. package/dist/psd.js.map +1 -1
  92. package/dist/psdReader.d.ts +12 -2
  93. package/dist/psdReader.js +720 -421
  94. package/dist/psdReader.js.map +1 -1
  95. package/dist/psdWriter.d.ts +3 -0
  96. package/dist/psdWriter.js +167 -130
  97. package/dist/psdWriter.js.map +1 -1
  98. package/dist/text.js +143 -29
  99. package/dist/text.js.map +1 -1
  100. package/dist/utf8.js +36 -18
  101. package/dist/utf8.js.map +1 -1
  102. package/dist-es/abr.d.ts +11 -4
  103. package/dist-es/abr.js +363 -229
  104. package/dist-es/abr.js.map +1 -1
  105. package/dist-es/additionalInfo.d.ts +56 -2
  106. package/dist-es/additionalInfo.js +600 -364
  107. package/dist-es/additionalInfo.js.map +1 -1
  108. package/dist-es/ase.d.ts +6 -1
  109. package/dist-es/ase.js +61 -61
  110. package/dist-es/ase.js.map +1 -1
  111. package/dist-es/descriptor.d.ts +25 -6
  112. package/dist-es/descriptor.js +380 -135
  113. package/dist-es/descriptor.js.map +1 -1
  114. package/dist-es/effectsHelpers.js +12 -12
  115. package/dist-es/effectsHelpers.js.map +1 -1
  116. package/dist-es/engineData.d.ts +3 -1
  117. package/dist-es/engineData.js +34 -13
  118. package/dist-es/engineData.js.map +1 -1
  119. package/dist-es/engineData2.js +50 -21
  120. package/dist-es/engineData2.js.map +1 -1
  121. package/dist-es/helpers.d.ts +6 -3
  122. package/dist-es/helpers.js +22 -6
  123. package/dist-es/helpers.js.map +1 -1
  124. package/dist-es/imageResources.d.ts +15 -3
  125. package/dist-es/imageResources.js +529 -144
  126. package/dist-es/imageResources.js.map +1 -1
  127. package/dist-es/index.js +1 -0
  128. package/dist-es/index.js.map +1 -1
  129. package/dist-es/jpeg.js +30 -10
  130. package/dist-es/jpeg.js.map +1 -1
  131. package/dist-es/psd.d.ts +154 -18
  132. package/dist-es/psd.js.map +1 -1
  133. package/dist-es/psdReader.d.ts +12 -2
  134. package/dist-es/psdReader.js +720 -421
  135. package/dist-es/psdReader.js.map +1 -1
  136. package/dist-es/psdWriter.d.ts +3 -0
  137. package/dist-es/psdWriter.js +167 -130
  138. package/dist-es/psdWriter.js.map +1 -1
  139. package/dist-es/text.js +143 -29
  140. package/dist-es/text.js.map +1 -1
  141. package/dist-es/utf8.js +36 -18
  142. package/dist-es/utf8.js.map +1 -1
  143. package/package.json +2 -2
  144. package/src/abr.ts +380 -232
  145. package/src/additionalInfo.ts +781 -477
  146. package/src/ase.ts +66 -61
  147. package/src/descriptor.ts +386 -142
  148. package/src/effectsHelpers.ts +9 -9
  149. package/src/engineData.ts +36 -13
  150. package/src/engineData2.ts +468 -432
  151. package/src/helpers.ts +23 -5
  152. package/src/imageResources.ts +658 -167
  153. package/src/index.ts +1 -0
  154. package/src/jpeg.ts +27 -12
  155. package/src/psd.ts +158 -30
  156. package/src/psdReader.ts +732 -414
  157. package/src/psdWriter.ts +186 -132
  158. package/src/text.ts +139 -18
  159. package/src/utf8.ts +35 -21
package/README_PSD.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This document describes structure of the Psd object used in `readPsd` and `writePsd` functions, you can see instructions on how to use these functions in our [main README document](/README.md#functions)
4
4
 
5
- You can see examples of different PSD documents and their corresponding JSON data in our [test folder](/test/read). Each subfolder contains `src.psd` document and corresponding `data.json` file with object generated by our library. Additionally there is `canvas.png` file represending composite image data, `thumb.png` file representing thumbnail image data and `layer-#.png` files with image data of each layer.
5
+ You can see examples of different PSD documents and their corresponding JSON data in our [test folder](/test/read). Each subfolder contains `src.psd` document and corresponding `data.json` file with object generated by our library. Additionally there is `canvas.png` file representing composite image data, `thumb.png` file representing thumbnail image data and `layer-#.png` files with image data of each layer.
6
6
 
7
7
  ## Basic document structure
8
8
 
@@ -23,9 +23,9 @@ const psd: Psd = {
23
23
 
24
24
  ![](/files/width-height.png)
25
25
 
26
- - `channels` property specifies number of color channels in the document, it's usually 3 channels (red, green, and blue, when document is in typical RGB color mode) Other color modes will have different channel count (grayscale - 1 channel, CMYK - 4 channels). This property can be ommited when writing, this library only supports RGB color mode with 3 channels at the moment.
26
+ - `channels` property specifies number of color channels in the document, it's usually 3 channels (red, green, and blue, when document is in typical RGB color mode) Other color modes will have different channel count (grayscale - 1 channel, CMYK - 4 channels). This property can be omitted and is ignored when writing, this library only writes RGB color mode (3 channels, or 4 channels if composite image has transparency).
27
27
 
28
- - `bitsPerChannel` property specifies number of bits per each color channel, this value will ba 1 for one bit bitmap color mode and 8 in all other cases as this library is not supporting 16 or 32 bit color channels at the moment. It can also be ommited when writing a document and default value of 8 will be assumed.
28
+ - `bitsPerChannel` property specifies number of bits per each color channel, this value will be 1 for one bit bitmap color mode and 8, 16 or 32 in other cases. 16 and 32 bit documents can be read, but writing is only supported for 8 bits per channel (see [Bitmaps and image data](#bitmaps-and-image-data)). It can be omitted when writing a document and default value of 8 will be assumed.
29
29
 
30
30
  - `colorMode` specifies color mode of the PSD document.
31
31
 
@@ -45,27 +45,31 @@ const psd: Psd = {
45
45
  Lab = 9,
46
46
  }
47
47
  ```
48
- The library supports "Bitmap", "Grayscale" and "RGB" color modes at the moment. "Bitmap" and "Grayscale" colors will be converted to "RGB" colors when reading PSD file. Writing is only supported for "RGB" mode. The value can be ommited for writing and "RGB" color mode will be assumed.
48
+ The library supports reading "Bitmap", "Grayscale", "Indexed", "RGB" and "CMYK" color modes at the moment. Image data of "Bitmap", "Grayscale", "Indexed" and "CMYK" documents will be converted to RGB when reading PSD file (the `colorMode` field keeps the original value). CMYK image data is converted using approximation of U.S. Web Coated (SWOP) v2 profile (Photoshop's default CMYK profile), embedded color profile (`imageResources.iccProfile`) is not used, so colors of documents using other profiles can differ slightly from Photoshop. 32 bit CMYK documents are not supported. Writing is only supported for "RGB" mode. The value is ignored when writing and "RGB" color mode is always used.
49
+
50
+ - `palette` list of 256 RGB colors used by "Indexed" color mode, this property is only present when reading documents in "Indexed" color mode. It can be omitted when writing.
49
51
 
50
52
  - `canvas` (or `imageData`) is a property containing bitmap with composite image data for the entire document. PSD file contains this extra bitmap additionally to bitmaps of each layer. `canvas` field will be an instance of `HTMLCanvasElement` (in browser environment) or `Canvas` object of `node-canvas` library (in nodejs environment).
51
53
 
52
- You can choose to instead use `imageData` field by choosing `useImageData: true` option when reading PSD file. In that can `imageData` will be an instance of `ImageData` object, containing `width`, `height` and `data` properties. This is useful if you want to use bitmap data directly, and not use it for drawing using canvas. Additionally this will preserve accurate color information as canvas element will premultiply image alpha which will change color values slightly.
54
+ You can choose to instead use `imageData` field by choosing `useImageData: true` option when reading PSD file. In that case `imageData` will be a `PixelData` object, containing `width`, `height` and `data` properties (`data` is a byte array for 8 bit documents, see [Bitmaps and image data](#bitmaps-and-image-data) for 16 and 32 bit documents). `ImageData` object can also be used in place of `PixelData`. This is useful if you want to use bitmap data directly, and not use it for drawing using canvas. Additionally this will preserve accurate color information as canvas element will premultiply image alpha which will change color values slightly.
53
55
 
54
56
  If you don't need to use this field you can specify `skipCompositeImageData: true` option, while reading PSD file, to skip reading this field and save on processing time and memory usage.
55
57
 
56
58
  This image data is optional in PSD file so it may be missing in some PSD files that opted to skip it.
57
59
 
58
- When writing you can provide either `canvas` or `imageData` property and the library will use the one you provide. You can also skip the field entirely and not write this data at all as it's not needed by Photohop to read the file. It might be used in some other application, for thumbnails or by some old versions of Adobe software, so you may want to still provide it to remain compatible with those programs.
60
+ When writing you can provide either `canvas` or `imageData` property and the library will use the one you provide. You can also skip the field entirely and not write this data at all as it's not needed by Photoshop to read the file. It might be used in some other application, for thumbnails or by some old versions of Adobe software, so you may want to still provide it to remain compatible with those programs.
59
61
 
60
62
  If you're generating your own PSD file and want to provide this composite image data you will have to generate one yourself by composing all layer image data and effects yourself, this library does not provide any utilities to generate this image data for you.
61
63
 
64
+ - `rawCompositeData` and `rawCompositeDataInfo` are used instead of `canvas` / `imageData` when `useRawData: true` option is passed to `readPsd` function. They contain undecoded composite image data that can be decoded later using `getCompositeImageData` or `getCompositeCanvas` functions (see [main README document](/README.md#functions)). Similarly layers will have `rawData` field (containing both layer and mask channels) instead of decoded image data, which can be decoded using `getLayerImageData`, `getLayerMaskImageData` and other helper functions. When writing, layer `rawData` is used instead of `canvas` / `imageData`. It's written back unchanged if it matches the format of the written file (8 bit RGB data and the same PSD/PSB format), otherwise it's decoded and re-encoded (raw data with bit depth other than 8 bits can't be written and throws an error). `rawCompositeData` is ignored when writing.
65
+
62
66
  - `children` list of layers and groups at the root of the document. [see Layers and Groups](#layers-and-groups)
63
67
 
64
- - `imageResources` contains all document-wide parameters [see Image Resouces](#image-resources)
68
+ - `imageResources` contains all document-wide parameters [see Image Resources](#image-resources)
65
69
 
66
70
  - `linkedFiles` contains list of files linked in smart objects [see Smart Objects](#smart-objects)
67
71
 
68
- - `artboards` contains global options for artboards. Artboards is a feature in new versions of Photoshop that lets you have multiple canvases in a single PSD document. The information about positioning, name and color of each artboard is stored inside each layer, in `artboard` property. This property will be absent if the document does not have any artboards specified. It can be ommited when writing.
72
+ - `artboards` contains global options for artboards. Artboards is a feature in new versions of Photoshop that lets you have multiple canvases in a single PSD document. The information about positioning, name and color of each artboard is stored inside each layer, in `artboard` property. This property will be absent if the document does not have any artboards specified. It can be omitted when writing.
69
73
 
70
74
  ```ts
71
75
  type Artboards = {
@@ -81,7 +85,7 @@ const psd: Psd = {
81
85
  }
82
86
  ```
83
87
 
84
- - `annotations` contains array of annotations, this field will be absent if the document does not have any annotations. It can be ommited when writing. Sound annotations are not supported by this library right at the moment.
88
+ - `annotations` contains array of annotations, this field will be absent if the document does not have any annotations. It can be omitted when writing. Sound annotations are not decoded, their data is kept as raw `Uint8Array` buffer and written back unchanged.
85
89
 
86
90
  ![](/files/annotations.png)
87
91
 
@@ -101,19 +105,34 @@ const psd: Psd = {
101
105
  }
102
106
  ```
103
107
 
104
- - `globalLayerMaskInfo` don't really know what this is, it can be ommited when writing.
108
+ - `globalLayerMaskInfo` don't really know what this is, it can be omitted when writing.
105
109
 
106
- - `filterMask` don't really know what this is, it can be ommited when writing.
110
+ - `patterns` Document-level pattern resources (`Patt`/`Pat2`/`Pat3` blocks). Each entry is a `PatternInfo` object:
111
+
112
+ ```ts
113
+ interface PatternInfo {
114
+ name: string;
115
+ id: string;
116
+ x: number;
117
+ y: number;
118
+ bounds: { x: number; y: number; w: number, h: number; };
119
+ data: Uint8Array; // RGBA pixel data
120
+ }
121
+ ```
122
+
123
+ Reading supports raw and RLE compressed 8, 16 and 32 bit patterns in RGB, Grayscale, Indexed and CMYK color modes, all of them are converted to 8 bit RGBA pixel data. Zip-compressed patterns and patterns in other color modes are not supported (they are skipped). Patterns are always written in RGB color mode. Layer-effect pattern references (Pattern Overlay, stroke/vector fill) only carry a `name`/`id` and are not linked to these resources.
107
124
 
108
125
  ## Bitmaps and image data
109
126
 
110
- Image data can be accessed from `psd.canvas` or `layer.canvas` fields by default. These fields store regular HTMLCanvasElement (or node-canvas object when running in node.js). For 16bit and 32 bit documents image data will be converted to regular 8bit canvas (this will result in a loss of data, use `useImageData` option if you want to preserve precission of color data).
127
+ Image data can be accessed from `psd.canvas` or `layer.canvas` fields by default. These fields store regular HTMLCanvasElement (or node-canvas object when running in node.js). For 16bit and 32 bit documents image data will be converted to regular 8bit canvas (this will result in a loss of data, use `useImageData` option if you want to preserve precision of color data).
128
+
129
+ If `useImageData` option is set to true in read options then the image data will be available in `psd.imageData` and `layer.imageData` fields instead. Using image data option gives you direct access to pixel data without having to go through the canvas object, which bypasses alpha premultiplication and conversion from 16/32bit image data to 8bit canvas data.
111
130
 
112
- If `useImageData` option is set to true in read options then the image data will be available in `psd.imageData` and `layer.imageData` fields instead. Using image data option gives you direct access to pixel data without having to go through the canvas object, which bypasses alpha premultiplication and convertion from 16/32bit image data to 8bit canvas data.
131
+ 16bit and 32bit documents can only be read, writing is only supported for 8bit documents.
113
132
 
114
133
  For 16bit documents `imageData` fields will contain pixel data as `Uint16Array`, the values ranging from 0 to 65535.
115
134
 
116
- For 32bit documents `imageData` fields will contain pixel data as `Float32Array`, the values ranging from 0 to 1. 32bit values are in linear color space (as oposed to gamma corrected sRGB color). In order to convert the values to regular sRGB color space the values need to be gamma-corrected by using following conversion code (except alpha channel):
135
+ For 32bit documents `imageData` fields will contain pixel data as `Float32Array`, the values ranging from 0 to 1. 32bit values are in linear color space (as opposed to gamma corrected sRGB color). In order to convert the values to regular sRGB color space the values need to be gamma-corrected by using following conversion code (except alpha channel):
117
136
 
118
137
  ```js
119
138
  // convert 32bit linear to 8bit sRGB
@@ -134,7 +153,7 @@ var psd = {
134
153
  {
135
154
  name: "layer 1",
136
155
  // ... other fields
137
- }
156
+ },
138
157
  {
139
158
  name: "group 1",
140
159
  // ... other fields
@@ -156,7 +175,7 @@ var psd = {
156
175
 
157
176
  ### Layer types
158
177
 
159
- You can distinguish between different layer types by checking which properties thay have set on them. If a layer has `children` property set it meas the it's a group, if it has `text` property it's a text layer and so on. If you're only interested in the basic parsing of layers and want to just extract image data or layer parameter a simple parsing like this can be enough:
178
+ You can distinguish between different layer types by checking which properties they have set on them. If a layer has `children` property set it means that it's a group, if it has `text` property it's a text layer and so on. If you're only interested in the basic parsing of layers and want to just extract image data or layer parameter a simple parsing like this can be enough:
160
179
 
161
180
  ```js
162
181
  // simple parsing
@@ -194,7 +213,7 @@ function parseLayer(layer) {
194
213
  }
195
214
  ```
196
215
 
197
- But thake into account that a lot of properties are shared for different types of layers. Any layer can have a `mask` property for example.
216
+ But take into account that a lot of properties are shared for different types of layers. Any layer can have a `mask` property for example.
198
217
 
199
218
  ### Layer
200
219
 
@@ -232,11 +251,11 @@ Example layer structure:
232
251
  },
233
252
  ```
234
253
 
235
- - `top`, `left`, `bottom`, `right` properties specify location of layer image data withing the document. `top` specifies offset in pixel of the top of layer image data from the top edge of the document, `bottom` specifies offset of the bottom of the layer image data from the top adge of the document and similar for `left` and `right`.
254
+ - `top`, `left`, `bottom`, `right` properties specify location of layer image data within the document. `top` specifies offset in pixel of the top of layer image data from the top edge of the document, `bottom` specifies offset of the bottom of the layer image data from the top edge of the document and similar for `left` and `right`.
236
255
 
237
256
  This is necessary as layer image data can be smaller or large than the document size. This can cause in some cases the values of these fields to be negative. A value of `left: -100` means that the layer image data starts 100 pixels outside the left document edge. This can happen if you move the layer left beyond document edge in Photoshop.
238
257
 
239
- `top` and `left` values can be ommited when writing and will be assumed to be 0. `bottom` and `right` values can be ommited and will always be ignored when writing and will instead be calculated from `canvas` (or `imageData`) width and height.
258
+ `top` and `left` values can be omitted when writing and will be assumed to be 0. `bottom` and `right` values can be omitted and will be ignored when writing and will instead be calculated from `canvas` (or `imageData`) width and height (they are only used when writing layers with `rawData` field).
240
259
 
241
260
  - `blendMode` is a layer blending mode and will be one of the following values:
242
261
 
@@ -246,12 +265,12 @@ Example layer structure:
246
265
  'screen' | 'color dodge' | 'linear dodge' | 'lighter color' | 'overlay' |
247
266
  'soft light' | 'hard light' | 'vivid light' | 'linear light' | 'pin light' |
248
267
  'hard mix' | 'difference' | 'exclusion' | 'subtract' | 'divide' | 'hue' |
249
- 'saturation' | 'color' | 'luminosity'
268
+ 'saturation' | 'color' | 'luminosity' | 'linear height' | 'height' | 'subtraction'
250
269
  ```
251
270
 
252
- These values correspond to naming in layer blend mode dropdown. If ommited a value of `normal` will be assumed.
271
+ These values correspond to naming in layer blend mode dropdown. If omitted a value of `normal` will be assumed.
253
272
 
254
- [](/files/blend-modes.png)
273
+ ![](/files/blend-modes.png)
255
274
 
256
275
  - `canvas` (or `imageData`) see `canvas` property description in [Basic document structure](#basic-document-structure)
257
276
 
@@ -259,17 +278,19 @@ Example layer structure:
259
278
 
260
279
  Reading this property can be skipped if `skipLayerImageData: true` option is passed to `readPsd` function. This can be done to save on memory usage and processing time if layer image data is not needed.
261
280
 
262
- - `opacity` specifies level of layer transparency (the value range is from 0 to 1). Can be ommited when writing, a default value of 1 will be assumed.
281
+ - `opacity` specifies level of layer transparency (the value range is from 0 to 1). Can be omitted when writing, a default value of 1 will be assumed.
263
282
 
264
283
  ![](/files/opacity.png)
265
284
 
266
- - `clipping` indicates if layer clipping is enabled (if enabled the layer is clipped to the layer below it). Can be ommited when writing, a default value of `false` will be assumed.
285
+ - `clipping` indicates if layer clipping is enabled (if enabled the layer is clipped to the layer below it). Can be omitted when writing, a default value of `false` will be assumed.
267
286
 
268
287
  ![](/files/clipping.png)
269
288
 
270
289
  ![](/files/clipping-2.png)
271
290
 
272
- - `timestamp` timestamp of last time layer was modified (in unix time). Can be ommited when writing.
291
+ - `timestamp` timestamp of last time layer was modified (in unix time). Can be omitted when writing.
292
+
293
+ - `generatorSettings` Generator (Export As) settings of the layer, `exportOption` and `scaleSettings` are JSON strings. The same field on the document (`Psd` object) holds document generator settings, which can also have `assets` (Generator image assets settings) and `crema` (Export As document settings) JSON strings. Can be omitted when writing.
273
294
 
274
295
  - `transparencyProtected` and `protected` properties specify status of various locks that you can set for each layer.
275
296
 
@@ -278,18 +299,22 @@ Example layer structure:
278
299
  - `protected.position` indicates if moving layer is locked
279
300
  - `protected.composite` indicates if drawing on the layer is locked
280
301
  - `protected.transparency` indicates if drawing transparent pixels are locked
302
+ - `protected.artboards` indicates if auto-nesting of layers in and out of artboards is prevented (only present when set)
303
+ - `protected.all` indicates if "lock all" is enabled (only present when set)
281
304
 
282
- If the `transparencyProtected` is `true` but `protected.transparency` is `false` it means that the layer has "lock all" enabled. Both this fields can be ommited when writing, a values of `false` will be assumed for all of the ommited fields.
305
+ If the `transparencyProtected` is `true` but `protected.transparency` is `false` it means that the layer has "lock all" enabled. Both these fields can be omitted when writing, a value of `false` will be assumed for all of the omitted fields.
283
306
 
284
- - `hidden` indicates if the layer is hidden. Can be ommited when writing, a value of `false` will be assumed.
307
+ - `effectsOpen` indicates if effects/filters list of the layer is expanded in the layer list. Only present when set.
308
+
309
+ - `hidden` indicates if the layer is hidden. Can be omitted when writing, a value of `false` will be assumed.
285
310
 
286
311
  ![](/files/hidden.png)
287
312
 
288
- - `name` name of the layer, can be any unicode string, can be empty. Can be ommited when writing, a value of `''` will be assumed.
313
+ - `name` name of the layer, can be any unicode string, can be empty. Can be omitted when writing, a value of `''` will be assumed.
289
314
 
290
- - `nameSource` internal Photoshop information, can be ignored and ommited when writing.
315
+ - `nameSource` internal Photoshop information, can be ignored and omitted when writing.
291
316
 
292
- - `id` unique ID number for layer, it may be missing in some PSD files. Can be ommited when writing, but if provided it has to be a unique number, if duplicate IDs are found they will be changed to a unique ones when writing the file.
317
+ - `id` unique ID number for layer, it may be missing in some PSD files. Can be omitted when writing, but if provided it has to be a unique number, if duplicate IDs are found they will be changed to a unique ones when writing the file.
293
318
 
294
319
  - `layerColor` color of the layer in layer list, property will be missing or will be one of the following values:
295
320
 
@@ -299,9 +324,9 @@ Example layer structure:
299
324
 
300
325
  ![](/files/layer-color.png)
301
326
 
302
- - `version` _unknown functionality_
327
+ - `version` layer version, the Photoshop version of the layer format (`70` - Photoshop 7, `80` - CS, `110` - CS4, `120` - CS5, `130` - CS6 and newer versions). Internal Photoshop information, can be omitted when writing.
303
328
 
304
- - `referencePoint` _unknown functionality_
329
+ - `referencePoint` reference point of the layer (`x`, `y` in pixels). Photoshop updates it when the layer is moved, to keep content aligned to the layer position, like patterns of pattern overlay effect. It's `{ x: 0, y: 0 }` for layers that were never moved. Can be omitted when writing.
305
330
 
306
331
  - `mask` Layer mask, property has the following structure.
307
332
 
@@ -320,7 +345,7 @@ Example layer structure:
320
345
  vectorMaskDensity?: number;
321
346
  vectorMaskFeather?: number;
322
347
  canvas?: HTMLCanvasElement;
323
- imageData?: ImageData;
348
+ imageData?: PixelData;
324
349
  }
325
350
  ```
326
351
 
@@ -330,7 +355,9 @@ Example layer structure:
330
355
 
331
356
  `fromVectorData` Specifies if the mask image data was generated from `vectorMask`, if `fromVectorData` is set to false and both `vectorMask` and `mask` properties are present it means that the layer has 2 active masks, bitmap mask and a vector mask.
332
357
 
333
- `mask` property will be missing when layer has no mask, it can be ommited when writing.
358
+ `mask` property will be missing when layer has no mask, it can be omitted when writing.
359
+
360
+ - `realMask` "Real user mask", second layer mask with the same structure as `mask`, present in some files when layer has both a bitmap mask and a vector mask. It can be omitted when writing.
334
361
 
335
362
  - `effects` Object describing layer "Blending Options"
336
363
 
@@ -353,20 +380,18 @@ Example layer structure:
353
380
  satin?: LayerEffectSatin;
354
381
  stroke?: LayerEffectStroke[];
355
382
  gradientOverlay?: LayerEffectGradientOverlay[];
356
- patternOverlay?: LayerEffectPatternOverlay; // not supported yet
383
+ patternOverlay?: LayerEffectPatternOverlay; // pattern is referenced only by name/id
357
384
  }
358
385
  ```
359
386
 
360
387
  Some of the effects (specified here as arrays) can be specified multiple times. This is new feature, only supported in more recent versions of Photoshop.
361
388
 
362
- This property is not present if there are not blending options set for the layer. This property can be ommited when writing.
389
+ This property is not present if there are not blending options set for the layer. This property can be omitted when writing.
363
390
 
364
391
  - `text` text properties of text layer
365
392
 
366
393
  _TODO_
367
394
 
368
- - `patterns` Document-level pattern resources (`Patt`/`Pat2`/`Pat3` blocks). Each entry is a `PatternInfo` with RGBA pixel `data` and `bounds`. Reading and writing support raw and RLE compression in RGB/Grayscale color modes; zip-compressed, Indexed and 16-bit patterns are not supported. Layer-effect pattern references (Pattern Overlay, stroke/vector fill) still only carry a `name`/`id` and are not linked to these resources.
369
-
370
395
  - `vectorFill` Fill color, gradient or pattern for the vector mask. Use `type` field to distinguish between different vector fill types, like this:
371
396
 
372
397
  ```ts
@@ -408,13 +433,32 @@ Example layer structure:
408
433
  }
409
434
  ```
410
435
 
411
- - `vectorMask` Specifies vector mask used by `vectorFill` and `vectorStroke` to draw vector images.
436
+ - `vectorMask` Specifies vector mask used by `vectorFill` and `vectorStroke` to draw vector images. For layers without `vectorFill` it acts as a regular vector mask of the layer (clipping layer content to the path). This property has following structure:
412
437
 
413
- _TODO: expand this description_
438
+ ```ts
439
+ type LayerVectorMask = {
440
+ invert?: boolean; // mask is inverted
441
+ notLink?: boolean; // mask is not linked to the layer (doesn't move with layer content)
442
+ disable?: boolean; // mask is disabled
443
+ fillStartsWithAllPixels?: boolean; // initial fill rule, area outside of all paths is filled
444
+ clipboard?: { top: number; left: number; bottom: number; right: number; resolution: number; }; // clipboard record, raw values
445
+ paths: BezierPath[];
446
+ };
414
447
 
415
- - `usingAlignedRendering` _unknown functionality_
448
+ type BezierPath = {
449
+ open: boolean; // path is open (not closed)
450
+ operation?: 'combine' | 'subtract' | 'intersect' | 'exclude'; // how the path is combined with previous paths
451
+ fillRule: 'even-odd' | 'non-zero';
452
+ knots: BezierKnot[];
453
+ };
416
454
 
417
- - `pathList` _not supported yet_
455
+ type BezierKnot = {
456
+ linked: boolean; // control points are linked (smooth point)
457
+ points: number[]; // [x0, y0, x1, y1, x2, y2] - preceding control point, anchor point and leaving control point in pixels
458
+ };
459
+ ```
460
+
461
+ - `usingAlignedRendering` "Align Edges" option of shape layers, snaps vector shape edges to pixel grid. Photoshop stores it on shape layers.
418
462
 
419
463
  - `adjustment` indicates that the layer is an adjustment layer. Adjustment layer do not have image data. This property is not present on non-adjustment layers.
420
464
 
@@ -438,11 +482,38 @@ Example layer structure:
438
482
 
439
483
  - `placedLayer` indicates that this is smart object layer, see [Smart Objects section](#smart-objects) for more information. This property is only present on smart object layers.
440
484
 
441
- - `vectorOrigination` _TODO_
485
+ - `vectorOrigination` Live shape properties of shape layers (shapes drawn with rectangle, ellipse, polygon, line, etc. tools that keep their original parameters editable in Properties panel). Contains one item in `keyDescriptorList` for each live shape in the layer's vector mask. Each item has the following structure:
442
486
 
443
- - `compositorUsed` _internal photoshop information_
487
+ ```ts
488
+ type KeyDescriptorItem = {
489
+ keyOriginType?: number; // shape type: 1 - rectangle, 2 - rounded rectangle, 4 - line, 5 - ellipse, 8 - polygon
490
+ keyOriginResolution?: number; // document resolution the shape was created with
491
+ keyOriginRRectRadii?: { topRight: UnitsValue; topLeft: UnitsValue; bottomLeft: UnitsValue; bottomRight: UnitsValue; }; // corner radii of the rectangle
492
+ keyOriginShapeBoundingBox?: { top: UnitsValue; left: UnitsValue; bottom: UnitsValue; right: UnitsValue; }; // bounds of the shape
493
+ keyOriginBoxCorners?: { x: number; y: number; }[]; // 4 corners of the shape bounding box (top-left, top-right, bottom-right, bottom-left)
494
+ transform?: number[]; // 2d transform matrix of the shape [xx, xy, yx, yy, tx, ty]
495
+ keyShapeInvalidated?: boolean; // shape path was edited directly and is no longer a live shape
496
+ };
497
+ ```
444
498
 
445
- - `artboard` Artboard location and parameters, this property is only present when using artboards. Artbord is object is following this structure:
499
+ - `compositorUsed` information about the compositing engine Photoshop used to render the image when saving the file. It's informational only and doesn't need to be provided when writing. Photoshop stores it on the document (`Psd` object), not on individual layers. Example value:
500
+
501
+ ```js
502
+ compositorUsed: {
503
+ description: '',
504
+ reason: '',
505
+ engine: 'compCoreGPU', // 'compCore', 'compCoreGPU' or 'umerge' (older compositor, used when CompCore is disabled)
506
+ version: { major: 1, minor: 3, fix: 0 }, // compositor version
507
+ photoshopVersion: { major: 27, minor: 7, fix: 0 },
508
+ enableCompCore: 'feature',
509
+ enableCompCoreGPU: 'feature',
510
+ enableCompCoreThreads: 'feature',
511
+ compCoreSupport: 'supported', // 'supported' or 'featureDisabled'
512
+ compCoreGPUSupport: 'supported', // 'supported' or 'featureDisabled'
513
+ }
514
+ ```
515
+
516
+ - `artboard` Artboard location and parameters, this property is only present when using artboards. Artboard object has the following structure:
446
517
 
447
518
  ```ts
448
519
  type Artboard = {
@@ -460,19 +531,30 @@ Example layer structure:
460
531
 
461
532
  ![](/files/advanced-blending-options.png)
462
533
 
463
- - `fillOpacity`"Fill Opacity" level (value ranges from 0 to 1)
534
+ - `fillOpacity` "Fill Opacity" level (value ranges from 0 to 1)
464
535
 
465
536
  ![](/files/fill-opacity.png)
466
537
  - `knockout` "Knockout" value
467
- - `blendClippendElements` "Blend Clipped Layers as Group" value
538
+ - `blendClippendElements` "Blend Clipped Layers as Group" value (has to be set to `true` when using `color burn` blend mode)
468
539
  - `blendInteriorElements` "Blend Interior Effects as Group" value
469
540
  - `transparencyShapesLayer` "Transparency Shapes Layer" value
541
+ - `layerMaskAsGlobalMask` "Layer Mask Hides Effects" value
542
+ - `channelBlendingRestrictions` list of disabled color channels ("Channels" checkboxes), channel indices start from 0
543
+ - `blendingRanges` "Blend If" ranges
470
544
  - `linkGroup` and `linkGroupEnabled` Layers with the same `linkGroup` value are linked together for moving/transforming. `0` value means no linking is active.
471
545
 
472
546
  ![](/files/linked-layers.png)
473
547
 
474
548
  - `engineData` internal text information
475
549
 
550
+ - `animationFrames`, `animationFrameFlags` and `timeline` per-layer animation frame and video timeline data, see [psd.ts file](/src/psd.ts) for structure.
551
+
552
+ - `comps` per-layer settings for layer comps (see `layerComps` in [Image Resources](#image-resources)).
553
+
554
+ - `filterMask`, `userMask` and `filterEffectsMasks` additional mask information, `userMask.opacity` and `filterMask.opacity` values range from 0 to 1.
555
+
556
+ - `pixelSource` video layer source information.
557
+
476
558
  ### Group
477
559
 
478
560
  Example group structure:
@@ -518,17 +600,17 @@ Groups don't have `canvas` / `imageData` property, as you can't draw directly on
518
600
 
519
601
  **Group-only fields:**
520
602
 
521
- - `children` contains list of all layers in this group. **Cannot** be ommited when writing, without this field a group will be assumed to be a regular layer. Use empty `children` array when writing empty group.
603
+ - `children` contains list of all layers in this group. **Cannot** be omitted when writing, without this field a group will be assumed to be a regular layer. Use empty `children` array when writing empty group.
522
604
 
523
- - `opened` indicates if the group is expanded or collapsed in the layer list. If ommited a default values of `true` will be assumed.
605
+ - `opened` indicates if the group is expanded or collapsed in the layer list. If omitted a default value of `true` will be assumed.
524
606
 
525
607
  ![](/files/group-open.png)
526
608
 
527
- - `sectionDivider` internal Photoshop property, can be ignored and ommited when writing.
609
+ - `sectionDivider` internal Photoshop property, can be ignored and omitted when writing.
528
610
 
529
611
  ## Image Resources
530
612
 
531
- Image resources are global document settings. Any of these settings can be ommited when writing. PSD file can have following global options:
613
+ Image resources are global document settings, stored in `psd.imageResources` field. Any of these settings can be omitted when writing. PSD file can have following global options:
532
614
 
533
615
  - `versionInfo` Version information of Program that generated the PSD file, example value:
534
616
 
@@ -551,7 +633,7 @@ Image resources are global document settings. Any of these settings can be ommit
551
633
  }
552
634
  ```
553
635
 
554
- - `gridAndGuidesInformation` Information about document guides
636
+ - `gridAndGuidesInformation` Information about document grid and guides. Guide `location` is specified in pixels, `grid` values are specified in 1/32 pixel units (`576` is 18 pixels). Guides can also have `color` (RGB, Photoshop default is `{ r: 74, g: 255, b: 255 }`) and unique `id` (GUID string), guide ids are only written if all guides have them.
555
637
 
556
638
  ![](/files/guides.png)
557
639
 
@@ -566,7 +648,9 @@ Image resources are global document settings. Any of these settings can be ommit
566
648
  "guides": [
567
649
  {
568
650
  "location": 531.4375,
569
- "direction": "vertical" // "horizontal" or "vertical"
651
+ "direction": "vertical", // "horizontal" or "vertical"
652
+ "color": { "r": 74, "g": 255, "b": 255 },
653
+ "id": "8544d157-6d38-7249-8b2c-56d4a2d49c08"
570
654
  },
571
655
  // ... more guides here ...
572
656
  ]
@@ -586,30 +670,84 @@ Image resources are global document settings. Any of these settings can be ommit
586
670
  },
587
671
  ```
588
672
 
589
- - `thumbnail` Canvas element with thumbnail image for the document, this property can be missing in some PSD files. This property can be ommited when writing if there's no need to support tumbnails, this field can be automatically generated from composite image data if `generateThumbnail: true` option is passed to `writePsd` function.
673
+ - `thumbnail` Canvas element with thumbnail image for the document, this property can be missing in some PSD files. This property can be omitted when writing if there's no need to support thumbnails, this field can be automatically generated from composite image data if `generateThumbnail: true` option is passed to `writePsd` function.
590
674
 
591
- - `thumbnailRaw` This property will be used instead if `useRawThumbnail` option is specitied when reading PSD file.
675
+ - `thumbnailRaw` This property will be used instead if `useRawThumbnail` option is specified when reading PSD file. It contains `width`, `height` and `data` (JPEG encoded thumbnail) fields. Uncompressed (raw RGB) thumbnails are only read into `thumbnail` field.
592
676
 
593
677
  - `xmpMetadata` XMP metadata. File info as XML description. See http://www.adobe.com/devnet/xmp/
594
678
 
595
679
  - `iccUntaggedProfile` ICC Untagged Profile
596
680
 
597
- - `printInformation`, `printScale` and `printFlags` Specifies options for printing the document.
598
-
599
- - `layerState` _TODO_
600
- - `layersGroup` _TODO_
601
- - `layerGroupsEnabledId` _TODO_
602
- - `alphaIdentifiers` _TODO_
603
- - `alphaChannelNames` _TODO_
604
- - `globalAngle` _TODO_
605
- - `globalAltitude` _TODO_
606
- - `urlsList` _TODO_
607
- - `captionDigest` _TODO_
608
- - `backgroundColor` _TODO_
609
- - `idsSeedNumber` _TODO_
610
- - `pathSelectionState` _TODO_
611
- - `imageReadyVariables` _TODO_
612
- - `imageReadyDataSets` _TODO_
681
+ - `iccProfile` raw ICC color profile data (`Uint8Array`). Documents are always written in RGB color mode, so `iccProfile`, `indexedColorCount`, `transparencyIndex`, `alphaChannelDisplayInfo`, halftone screens and transfer functions are not written if `colorMode` of the document is set to color mode other than RGB.
682
+
683
+ - `exifData` raw EXIF data (`Uint8Array`, TIFF format).
684
+
685
+ - `iptcData` raw IPTC-NAA record (`Uint8Array`).
686
+
687
+ - `windowsDevMode` raw Windows DEVMODE structure with printer settings (`Uint8Array`).
688
+
689
+ - `outputSettings` Save for Web output settings, raw descriptor object (with `_name` and `_classID` fields), written back unchanged.
690
+
691
+ - `colorHalftoneScreens`, `grayscaleHalftoneScreens`, `colorTransferFunctions` and `grayscaleTransferFunctions` halftone screens and transfer functions used for printing.
692
+
693
+ - `printInformation`, `printScale`, `printFlags`, `printFlagsInfo` and `printStyle` Specifies options for printing the document.
694
+
695
+ - `indexedColorCount` and `transparencyIndex` number of used colors and index of transparent color of "Indexed" color mode palette, pixels with transparent color are read as transparent in composite image.
696
+
697
+ - `alphaChannelDisplayInfo` display options (color, opacity and kind) of alpha and spot channels, in the same order as `alphaChannelNames`. Colors in color spaces not supported by the library are stored in `rawColor` field (color space id and 4 raw values) instead of `color`. Obsolete display info resource (Photoshop 5) is also read into this field, it is always written in the newer format.
698
+
699
+ - `colorSamplers` positions (in pixels) and color spaces of color samplers (Photoshop 5 format).
700
+
701
+ - `effectsVisible` global flag to show or hide all layer effects (Photoshop only writes it when effects are hidden).
702
+
703
+ - `layerComps` list of layer comps defined in the document, per-layer settings are stored in `comps` field of each layer.
704
+
705
+ - `animations`, `onionSkins`, `timelineInformation` and `sheetDisclosure` frame animation and video timeline settings.
706
+
707
+ - `slices` list of slices defined in the document.
708
+
709
+ - `countInformation` data of the Count tool.
710
+
711
+ - `copyrighted` and `url` copyright status and URL from File Info dialog.
712
+
713
+ - `layerState` index of the target (active) layer, `0` is the bottom layer.
714
+
715
+ - `alphaChannelNames` names of alpha channels (saved selections) and spot channels stored in the composite image, in channel order. Photoshop also lists merged transparency as the first channel named `"Transparency"` in some documents. Written to both the legacy (Pascal string) and the unicode image resource.
716
+
717
+ - `alphaIdentifiers` unique identifiers of alpha channels, in the same order as `alphaChannelNames`.
718
+
719
+ - `globalAngle` and `globalAltitude` global light angle (in degrees) and altitude (in degrees) used by layer effects with `useGlobalLight` option enabled.
720
+
721
+ - `urlsList` list of URLs assigned to slices, `id` is the id of the slice (`ref` is always `'slice'`).
722
+
723
+ - `captionDigest` MD5 digest of the IPTC data (`iptcData`), as 32 character hex string.
724
+
725
+ - `backgroundColor` background color of the color picker (tools panel) at the time the document was saved.
726
+
727
+ - `idsSeedNumber` base value that new layer IDs are generated from (Photoshop uses higher value if existing IDs already exceed it).
728
+
729
+ - `pathSelectionState` reference to selected path in the paths panel, for example `['Path.vectorMask', 'Rectangle 1']` for vector mask of the layer named "Rectangle 1", or `['Ordn.Trgt']` for the target path.
730
+
731
+ - `savedPaths` saved paths from the Paths panel. Path data uses the same structure as layer `vectorMask` (points are in document pixels):
732
+
733
+ ```ts
734
+ type SavedPath = {
735
+ name: string;
736
+ symmetryMode?: string; // raw enum value from paths with symmetry, e.g. 'pathSymmetryModeBasicPath'
737
+ fillStartsWithAllPixels?: boolean;
738
+ clipboard?: { top: number; left: number; bottom: number; right: number; resolution: number; };
739
+ paths: BezierPath[];
740
+ vectorOrigination?: { keyDescriptorList: KeyDescriptorItem[]; }; // live shape properties, same as layer `vectorOrigination`
741
+ };
742
+ ```
743
+
744
+ Photoshop stores each path in a separate image resource (named using legacy encoding, non-ASCII characters are written as `?`) and unicode names in `pths` additional info, which is written whenever `savedPaths` is set (Photoshop writes empty `pths` for documents without paths, which reads as an empty array).
745
+
746
+ - `workPath` temporary "Work Path" from the Paths panel, same structure as saved path without `name`.
747
+
748
+ - `clippingPath` saved path used as clipping path (when placing image in other applications), `name` refers to name of one of `savedPaths`, `flatness` is in device pixels (`0` for printer default).
749
+
750
+ - `imageReadyVariables` and `imageReadyDataSets` XML of variables and data sets (Image > Variables), stored as raw strings.
613
751
 
614
752
  ## Smart Objects
615
753
 
@@ -617,32 +755,55 @@ Layers with `placedLayer` property are smart object layers. `placedLayer` proper
617
755
 
618
756
  ```ts
619
757
  interface PlacedLayer {
620
- id: string; // id of linked image file (psd.linkedFiles)
758
+ id: string; // id of linked image file (psd.linkedFiles), must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
621
759
  placed?: string; // unique id
622
760
  type: PlacedLayerType;
761
+ external?: boolean; // linked smart object (linked file is stored outside of the document)
762
+ pageNumber?: number;
763
+ totalPages?: number;
764
+ frameStep?: { numerator: number; denominator: number; };
765
+ duration?: { numerator: number; denominator: number; };
766
+ frameCount?: number;
623
767
  transform: number[]; // x, y of 4 corners of the transform
624
768
  nonAffineTransform?: number[]; // x, y of 4 corners of the transform
625
- width?: number;
626
- height?: number;
769
+ width?: number; // width of the linked image
770
+ height?: number; // height of the linked image
627
771
  resolution?: UnitsValue;
628
- warp?: Warp;
772
+ warp?: Warp; // warp coordinates are relative to the linked image size
629
773
  crop?: number;
774
+ comp?: number;
775
+ compInfo?: { compID: number; originalCompID: number; };
776
+ filter?: PlacedLayerFilter; // smart filters
630
777
  }
631
778
  ```
632
779
 
780
+ Smart filters that are not supported by this library are skipped when reading (an error is thrown instead if `throwForMissingFeatures` option is set).
781
+
633
782
  The Psd object has `linkedFiles` property, that specifies list of all files linked in smart objects. Each linked file has following structure:
634
783
 
635
784
  ```ts
636
785
  interface LinkedFile {
637
- id: string;
786
+ id: string; // must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
638
787
  name: string;
639
788
  type?: string;
640
789
  creator?: string;
641
790
  data?: Uint8Array;
642
- time?: Date; // for external files
791
+ time?: string; // for external files, date in ISO format
792
+ descriptor?: {
793
+ compInfo: { compID: number; originalCompID: number; };
794
+ };
643
795
  childDocumentID?: string;
644
796
  assetModTime?: number;
645
797
  assetLockedState?: number;
798
+
799
+ // external files
800
+ linkedFile?: {
801
+ fileSize: number;
802
+ name: string;
803
+ fullPath: string;
804
+ originalPath: string;
805
+ relativePath: string;
806
+ };
646
807
  }
647
808
  ```
648
809
 
@@ -674,7 +835,7 @@ interface LinkedFile {
674
835
  psd.linkedFiles = [
675
836
  {
676
837
  "id": "20953ddb-9391-11ec-b4f1-c15674f50bc4",
677
- "name": "cat.png"
838
+ "name": "cat.png",
678
839
  "data": fileContentsAsUint8Array,
679
840
  }
680
841
  ];
@@ -682,7 +843,7 @@ interface LinkedFile {
682
843
 
683
844
  ## Units value
684
845
 
685
- Some fields in the PSD document specity a value with units, those fields use `UnitsValue` type:
846
+ Some fields in the PSD document specify a value with units, those fields use `UnitsValue` type:
686
847
 
687
848
  ```ts
688
849
  interface UnitsValue {
@@ -707,7 +868,7 @@ Many fields in PSD file support passing color in different color formats (RGBA,
707
868
  ```ts
708
869
  type RGBA = { r: number; g: number; b: number; a: number; }; // values from 0 to 255
709
870
  type RGB = { r: number; g: number; b: number; }; // values from 0 to 255
710
- type FRGB = { fr: number; fg: number; fb: number; }; // values from 0 to 1 (can be above 1)
871
+ type FRGB = { fr: number; fg: number; fb: number; }; // values from 0 to 1 (can be above 1, can be negative)
711
872
  type HSB = { h: number; s: number; b: number; }; // values from 0 to 1
712
873
  type CMYK = { c: number; m: number; y: number; k: number; }; // values from 0 to 255
713
874
  type LAB = { l: number; a: number; b: number; }; // values `l` from 0 to 1; `a` and `b` from -1 to 1
@@ -734,7 +895,7 @@ if ('l' in color) {
734
895
  // color is Grayscale
735
896
  } else if ('a' in color) {
736
897
  // color is RGBA
737
- } else if ('rf' in color) {
898
+ } else if ('fr' in color) {
738
899
  // color is FRGB
739
900
  } else {
740
901
  // color is RGB