ag-psd 32.0.0 → 34.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.7.0-x64-ef5a0af0/03e19709 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/05135617 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/1130885f +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/226e2801 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/2a19133e +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/4511bacf +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/68416cb2 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/71df9cb3 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/7ea06cea +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/87cf2209 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/932f0770 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/acc36e66 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/b3c2fab7 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/c0b789d2 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/c314aece +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/cfc49f4f +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/cff9434a +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/d13d7610 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/dc86f000 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/e03e2acd +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/e6745c2b +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/e6b99945 +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/eeeebdfe +0 -0
- package/.v8-cache/v24.7.0-x64-ef5a0af0/f6fd8125 +0 -0
- package/CHANGELOG.md +100 -0
- package/LICENSE +5 -0
- package/README.md +4 -7
- package/README_PSD.md +261 -84
- package/TODO.md +13 -84
- package/dist/abr.d.ts +11 -4
- package/dist/abr.js +362 -230
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.d.ts +56 -2
- package/dist/additionalInfo.js +828 -361
- package/dist/additionalInfo.js.map +1 -1
- package/dist/ase.d.ts +6 -1
- package/dist/ase.js +61 -61
- package/dist/ase.js.map +1 -1
- package/dist/bundle.js +3321 -1364
- package/dist/descriptor.d.ts +28 -13
- package/dist/descriptor.js +295 -241
- package/dist/descriptor.js.map +1 -1
- package/dist/helpers.d.ts +7 -1
- package/dist/helpers.js +246 -4
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.d.ts +15 -3
- package/dist/imageResources.js +586 -144
- package/dist/imageResources.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jpeg.js +8 -8
- package/dist/jpeg.js.map +1 -1
- package/dist/psd.d.ts +292 -19
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.d.ts +10 -0
- package/dist/psdReader.js +424 -216
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +2 -0
- package/dist/psdWriter.js +373 -113
- package/dist/psdWriter.js.map +1 -1
- package/dist/text.d.ts +32 -1
- package/dist/text.js +75 -6
- package/dist/text.js.map +1 -1
- package/dist/utf8.js +0 -3
- package/dist/utf8.js.map +1 -1
- package/dist-es/abr.d.ts +11 -4
- package/dist-es/abr.js +362 -230
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.d.ts +56 -2
- package/dist-es/additionalInfo.js +828 -361
- package/dist-es/additionalInfo.js.map +1 -1
- package/dist-es/ase.d.ts +6 -1
- package/dist-es/ase.js +61 -61
- package/dist-es/ase.js.map +1 -1
- package/dist-es/descriptor.d.ts +28 -13
- package/dist-es/descriptor.js +295 -241
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/helpers.d.ts +7 -1
- package/dist-es/helpers.js +246 -4
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.d.ts +15 -3
- package/dist-es/imageResources.js +586 -144
- package/dist-es/imageResources.js.map +1 -1
- package/dist-es/index.d.ts +1 -0
- package/dist-es/index.js +1 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/jpeg.js +8 -8
- package/dist-es/jpeg.js.map +1 -1
- package/dist-es/psd.d.ts +292 -19
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.d.ts +10 -0
- package/dist-es/psdReader.js +424 -216
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +2 -0
- package/dist-es/psdWriter.js +373 -113
- package/dist-es/psdWriter.js.map +1 -1
- package/dist-es/text.d.ts +32 -1
- package/dist-es/text.js +75 -6
- package/dist-es/text.js.map +1 -1
- package/dist-es/utf8.js +0 -3
- package/dist-es/utf8.js.map +1 -1
- package/package.json +2 -2
- package/perf.js +312 -9
- package/src/abr.ts +382 -235
- package/src/additionalInfo.ts +1071 -482
- package/src/ase.ts +66 -61
- package/src/descriptor.ts +291 -242
- package/src/helpers.ts +266 -3
- package/src/imageResources.ts +736 -169
- package/src/index.ts +1 -0
- package/src/jpeg.ts +8 -8
- package/src/psd.ts +271 -32
- package/src/psdReader.ts +440 -221
- package/src/psdWriter.ts +402 -110
- package/src/text.ts +93 -7
- package/src/utf8.ts +0 -4
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
|
|
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
|

|
|
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
|
|
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
|
|
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 (see [Bitmaps and image data](#bitmaps-and-image-data)). Documents are written with the same bit depth, 16 and 32 bits are supported for "RGB" and "Grayscale" color modes and 16 bits for "CMYK" color mode. It can be omitted when writing a document and default value of 8 will be assumed (1 for "Bitmap" color mode).
|
|
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"
|
|
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. Documents are written in the same color mode ("Bitmap", "Grayscale", "Indexed", "RGB" and "CMYK" color modes are supported for writing, "RGB" is used if the value is omitted), image data is converted from RGB to the color mode of the document (CMYK colors are converted using inverse of the approximation used for reading, "Indexed" color mode uses the closest color from the `palette`). "Bitmap" and "Indexed" documents can't have layers (Photoshop doesn't support them in these color modes), only composite image is written.
|
|
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
|
|
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
|
|
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 (the same color mode, bit depth and PSD/PSB format), otherwise it's decoded and re-encoded. `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
|
|
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
|
|
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
|
|
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
|

|
|
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
|
|
108
|
+
- `globalLayerMaskInfo` don't really know what this is, it can be omitted when writing.
|
|
109
|
+
|
|
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
|
+
```
|
|
105
122
|
|
|
106
|
-
-
|
|
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
|
|
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).
|
|
111
128
|
|
|
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
|
|
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.
|
|
130
|
+
|
|
131
|
+
When writing, image data can be provided as canvas or `PixelData` with 8 bit (`Uint8Array` or `Uint8ClampedArray`), 16 bit (`Uint16Array`) or 32 bit (`Float32Array`) values regardless of the bit depth of the document, it's converted to the bit depth of the document. 16 and 32 bit layers are stored in `Lr16` / `Lr32` sections and compressed using zip compression with prediction (like Photoshop does).
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
+

|
|
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
|
|
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
|

|
|
265
284
|
|
|
266
|
-
- `clipping` indicates if layer clipping is enabled (if enabled the layer is clipped to the layer below it). Can be
|
|
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
|

|
|
269
288
|
|
|
270
289
|

|
|
271
290
|
|
|
272
|
-
- `timestamp` timestamp of last time layer was modified (in unix time). Can be
|
|
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,30 +299,35 @@ 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)
|
|
304
|
+
|
|
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.
|
|
281
306
|
|
|
282
|
-
|
|
307
|
+
- `effectsOpen` indicates if effects/filters list of the layer is expanded in the layer list. Only present when set.
|
|
283
308
|
|
|
284
|
-
- `hidden` indicates if the layer is hidden. Can be
|
|
309
|
+
- `hidden` indicates if the layer is hidden. Can be omitted when writing, a value of `false` will be assumed.
|
|
285
310
|
|
|
286
311
|

|
|
287
312
|
|
|
288
|
-
- `name` name of the layer, can be any unicode string, can be empty. Can be
|
|
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
|
|
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
|
|
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
|
|
|
296
321
|
```ts
|
|
297
|
-
type LayerColor = 'none' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'violet' | 'gray'
|
|
322
|
+
type LayerColor = 'none' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'violet' | 'gray' |
|
|
323
|
+
'seafoam' | 'indigo' | 'magenta' | 'fuchsia'
|
|
298
324
|
```
|
|
299
325
|
|
|
300
326
|

|
|
301
327
|
|
|
302
|
-
- `version`
|
|
328
|
+
- `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
329
|
|
|
304
|
-
- `referencePoint`
|
|
330
|
+
- `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
331
|
|
|
306
332
|
- `mask` Layer mask, property has the following structure.
|
|
307
333
|
|
|
@@ -320,7 +346,7 @@ Example layer structure:
|
|
|
320
346
|
vectorMaskDensity?: number;
|
|
321
347
|
vectorMaskFeather?: number;
|
|
322
348
|
canvas?: HTMLCanvasElement;
|
|
323
|
-
imageData?:
|
|
349
|
+
imageData?: PixelData;
|
|
324
350
|
}
|
|
325
351
|
```
|
|
326
352
|
|
|
@@ -330,7 +356,9 @@ Example layer structure:
|
|
|
330
356
|
|
|
331
357
|
`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
358
|
|
|
333
|
-
`mask` property will be missing when layer has no mask, it can be
|
|
359
|
+
`mask` property will be missing when layer has no mask, it can be omitted when writing.
|
|
360
|
+
|
|
361
|
+
- `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
362
|
|
|
335
363
|
- `effects` Object describing layer "Blending Options"
|
|
336
364
|
|
|
@@ -353,20 +381,18 @@ Example layer structure:
|
|
|
353
381
|
satin?: LayerEffectSatin;
|
|
354
382
|
stroke?: LayerEffectStroke[];
|
|
355
383
|
gradientOverlay?: LayerEffectGradientOverlay[];
|
|
356
|
-
patternOverlay?: LayerEffectPatternOverlay; //
|
|
384
|
+
patternOverlay?: LayerEffectPatternOverlay; // pattern is referenced only by name/id
|
|
357
385
|
}
|
|
358
386
|
```
|
|
359
387
|
|
|
360
388
|
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
389
|
|
|
362
|
-
This property is not present if there are not blending options set for the layer. This property can be
|
|
390
|
+
This property is not present if there are not blending options set for the layer. This property can be omitted when writing.
|
|
363
391
|
|
|
364
|
-
- `text` text properties of text layer
|
|
392
|
+
- `text` text properties of text layer (type tool info of Photoshop 5 text layers is also read into this field, these layers are written in current format)
|
|
365
393
|
|
|
366
394
|
_TODO_
|
|
367
395
|
|
|
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
396
|
- `vectorFill` Fill color, gradient or pattern for the vector mask. Use `type` field to distinguish between different vector fill types, like this:
|
|
371
397
|
|
|
372
398
|
```ts
|
|
@@ -408,13 +434,32 @@ Example layer structure:
|
|
|
408
434
|
}
|
|
409
435
|
```
|
|
410
436
|
|
|
411
|
-
- `vectorMask` Specifies vector mask used by `vectorFill` and `vectorStroke` to draw vector images.
|
|
437
|
+
- `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
438
|
|
|
413
|
-
|
|
439
|
+
```ts
|
|
440
|
+
type LayerVectorMask = {
|
|
441
|
+
invert?: boolean; // mask is inverted
|
|
442
|
+
notLink?: boolean; // mask is not linked to the layer (doesn't move with layer content)
|
|
443
|
+
disable?: boolean; // mask is disabled
|
|
444
|
+
fillStartsWithAllPixels?: boolean; // initial fill rule, area outside of all paths is filled
|
|
445
|
+
clipboard?: { top: number; left: number; bottom: number; right: number; resolution: number; }; // clipboard record, raw values
|
|
446
|
+
paths: BezierPath[];
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
type BezierPath = {
|
|
450
|
+
open: boolean; // path is open (not closed)
|
|
451
|
+
operation?: 'combine' | 'subtract' | 'intersect' | 'exclude'; // how the path is combined with previous paths
|
|
452
|
+
fillRule: 'even-odd' | 'non-zero';
|
|
453
|
+
knots: BezierKnot[];
|
|
454
|
+
};
|
|
414
455
|
|
|
415
|
-
|
|
456
|
+
type BezierKnot = {
|
|
457
|
+
linked: boolean; // control points are linked (smooth point)
|
|
458
|
+
points: number[]; // [x0, y0, x1, y1, x2, y2] - preceding control point, anchor point and leaving control point in pixels
|
|
459
|
+
};
|
|
460
|
+
```
|
|
416
461
|
|
|
417
|
-
- `
|
|
462
|
+
- `usingAlignedRendering` "Align Edges" option of shape layers, snaps vector shape edges to pixel grid. Photoshop stores it on shape layers.
|
|
418
463
|
|
|
419
464
|
- `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
465
|
|
|
@@ -438,11 +483,38 @@ Example layer structure:
|
|
|
438
483
|
|
|
439
484
|
- `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
485
|
|
|
441
|
-
- `vectorOrigination`
|
|
486
|
+
- `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:
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
type KeyDescriptorItem = {
|
|
490
|
+
keyOriginType?: number; // shape type: 1 - rectangle, 2 - rounded rectangle, 4 - line, 5 - ellipse, 8 - polygon
|
|
491
|
+
keyOriginResolution?: number; // document resolution the shape was created with
|
|
492
|
+
keyOriginRRectRadii?: { topRight: UnitsValue; topLeft: UnitsValue; bottomLeft: UnitsValue; bottomRight: UnitsValue; }; // corner radii of the rectangle
|
|
493
|
+
keyOriginShapeBoundingBox?: { top: UnitsValue; left: UnitsValue; bottom: UnitsValue; right: UnitsValue; }; // bounds of the shape
|
|
494
|
+
keyOriginBoxCorners?: { x: number; y: number; }[]; // 4 corners of the shape bounding box (top-left, top-right, bottom-right, bottom-left)
|
|
495
|
+
transform?: number[]; // 2d transform matrix of the shape [xx, xy, yx, yy, tx, ty]
|
|
496
|
+
keyShapeInvalidated?: boolean; // shape path was edited directly and is no longer a live shape
|
|
497
|
+
};
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
- `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:
|
|
442
501
|
|
|
443
|
-
|
|
502
|
+
```js
|
|
503
|
+
compositorUsed: {
|
|
504
|
+
description: '',
|
|
505
|
+
reason: '',
|
|
506
|
+
engine: 'compCoreGPU', // 'compCore', 'compCoreGPU' or 'umerge' (older compositor, used when CompCore is disabled)
|
|
507
|
+
version: { major: 1, minor: 3, fix: 0 }, // compositor version
|
|
508
|
+
photoshopVersion: { major: 27, minor: 7, fix: 0 },
|
|
509
|
+
enableCompCore: 'feature',
|
|
510
|
+
enableCompCoreGPU: 'feature',
|
|
511
|
+
enableCompCoreThreads: 'feature',
|
|
512
|
+
compCoreSupport: 'supported', // 'supported' or 'featureDisabled'
|
|
513
|
+
compCoreGPUSupport: 'supported', // 'supported' or 'featureDisabled'
|
|
514
|
+
}
|
|
515
|
+
```
|
|
444
516
|
|
|
445
|
-
- `artboard` Artboard location and parameters, this property is only present when using artboards.
|
|
517
|
+
- `artboard` Artboard location and parameters, this property is only present when using artboards. Artboard object has the following structure:
|
|
446
518
|
|
|
447
519
|
```ts
|
|
448
520
|
type Artboard = {
|
|
@@ -460,19 +532,37 @@ Example layer structure:
|
|
|
460
532
|
|
|
461
533
|

|
|
462
534
|
|
|
463
|
-
- `fillOpacity`"Fill Opacity" level (value ranges from 0 to 1)
|
|
535
|
+
- `fillOpacity` "Fill Opacity" level (value ranges from 0 to 1)
|
|
464
536
|
|
|
465
537
|

|
|
466
538
|
- `knockout` "Knockout" value
|
|
467
|
-
- `blendClippendElements` "Blend Clipped Layers as Group" value
|
|
539
|
+
- `blendClippendElements` "Blend Clipped Layers as Group" value (has to be set to `true` when using `color burn` blend mode)
|
|
468
540
|
- `blendInteriorElements` "Blend Interior Effects as Group" value
|
|
469
541
|
- `transparencyShapesLayer` "Transparency Shapes Layer" value
|
|
542
|
+
- `layerMaskAsGlobalMask` "Layer Mask Hides Effects" value
|
|
543
|
+
- `vectorMaskAsGlobalMask` "Vector Mask Hides Effects" value
|
|
544
|
+
- `channelBlendingRestrictions` list of disabled color channels ("Channels" checkboxes), channel indices start from 0
|
|
545
|
+
- `blendingRanges` "Blend If" ranges
|
|
470
546
|
- `linkGroup` and `linkGroupEnabled` Layers with the same `linkGroup` value are linked together for moving/transforming. `0` value means no linking is active.
|
|
471
547
|
|
|
472
548
|

|
|
473
549
|
|
|
474
550
|
- `engineData` internal text information
|
|
475
551
|
|
|
552
|
+
- `animationFrames`, `animationFrameFlags` and `timeline` per-layer animation frame and video timeline data, see [psd.ts file](/src/psd.ts) for structure.
|
|
553
|
+
|
|
554
|
+
- `comps` per-layer settings for layer comps (see `layerComps` in [Image Resources](#image-resources)).
|
|
555
|
+
|
|
556
|
+
- `filterMask`, `userMask` and `filterEffectsMasks` additional mask information, `userMask.opacity` and `filterMask.opacity` values range from 0 to 1.
|
|
557
|
+
|
|
558
|
+
- `pixelSource` video layer source information.
|
|
559
|
+
|
|
560
|
+
- `pixelSourceData` raw data of video layer frames (`Uint8Array` for each entry).
|
|
561
|
+
|
|
562
|
+
- `framedGroup` frame settings of frame layers (created with Frame tool), `rect` of the frame, frame `type` (1 - rectangle, 2 - ellipse), `lockPPI`, `preferredResolution` and `savedIteratedName`.
|
|
563
|
+
|
|
564
|
+
- `foreignEffectId`, `animationEffects` (raw descriptor data) and `patternData` (patterns used by the layer, Photoshop 6) additional layer information.
|
|
565
|
+
|
|
476
566
|
### Group
|
|
477
567
|
|
|
478
568
|
Example group structure:
|
|
@@ -518,17 +608,17 @@ Groups don't have `canvas` / `imageData` property, as you can't draw directly on
|
|
|
518
608
|
|
|
519
609
|
**Group-only fields:**
|
|
520
610
|
|
|
521
|
-
- `children` contains list of all layers in this group. **Cannot** be
|
|
611
|
+
- `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
612
|
|
|
523
|
-
- `opened` indicates if the group is expanded or collapsed in the layer list. If
|
|
613
|
+
- `opened` indicates if the group is expanded or collapsed in the layer list. If omitted a default value of `true` will be assumed.
|
|
524
614
|
|
|
525
615
|

|
|
526
616
|
|
|
527
|
-
- `sectionDivider` internal Photoshop property, can be ignored and
|
|
617
|
+
- `sectionDivider` internal Photoshop property, can be ignored and omitted when writing.
|
|
528
618
|
|
|
529
619
|
## Image Resources
|
|
530
620
|
|
|
531
|
-
Image resources are global document settings. Any of these settings can be
|
|
621
|
+
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
622
|
|
|
533
623
|
- `versionInfo` Version information of Program that generated the PSD file, example value:
|
|
534
624
|
|
|
@@ -551,7 +641,7 @@ Image resources are global document settings. Any of these settings can be ommit
|
|
|
551
641
|
}
|
|
552
642
|
```
|
|
553
643
|
|
|
554
|
-
- `gridAndGuidesInformation` Information about document guides
|
|
644
|
+
- `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
645
|
|
|
556
646
|

|
|
557
647
|
|
|
@@ -566,7 +656,9 @@ Image resources are global document settings. Any of these settings can be ommit
|
|
|
566
656
|
"guides": [
|
|
567
657
|
{
|
|
568
658
|
"location": 531.4375,
|
|
569
|
-
"direction": "vertical" // "horizontal" or "vertical"
|
|
659
|
+
"direction": "vertical", // "horizontal" or "vertical"
|
|
660
|
+
"color": { "r": 74, "g": 255, "b": 255 },
|
|
661
|
+
"id": "8544d157-6d38-7249-8b2c-56d4a2d49c08"
|
|
570
662
|
},
|
|
571
663
|
// ... more guides here ...
|
|
572
664
|
]
|
|
@@ -586,30 +678,90 @@ Image resources are global document settings. Any of these settings can be ommit
|
|
|
586
678
|
},
|
|
587
679
|
```
|
|
588
680
|
|
|
589
|
-
- `thumbnail` Canvas element with thumbnail image for the document, this property can be missing in some PSD files. This property can be
|
|
681
|
+
- `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
682
|
|
|
591
|
-
- `thumbnailRaw` This property will be used instead if `useRawThumbnail` option is
|
|
683
|
+
- `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
684
|
|
|
593
685
|
- `xmpMetadata` XMP metadata. File info as XML description. See http://www.adobe.com/devnet/xmp/
|
|
594
686
|
|
|
595
687
|
- `iccUntaggedProfile` ICC Untagged Profile
|
|
596
688
|
|
|
597
|
-
- `
|
|
598
|
-
|
|
599
|
-
- `
|
|
600
|
-
|
|
601
|
-
- `
|
|
602
|
-
|
|
603
|
-
- `
|
|
604
|
-
|
|
605
|
-
- `
|
|
606
|
-
|
|
607
|
-
- `
|
|
608
|
-
|
|
609
|
-
- `
|
|
610
|
-
|
|
611
|
-
- `
|
|
612
|
-
|
|
689
|
+
- `iccProfile` raw ICC color profile data (`Uint8Array`).
|
|
690
|
+
|
|
691
|
+
- `exifData` raw EXIF data (`Uint8Array`, TIFF format).
|
|
692
|
+
|
|
693
|
+
- `iptcData` raw IPTC-NAA record (`Uint8Array`).
|
|
694
|
+
|
|
695
|
+
- `windowsDevMode` raw Windows DEVMODE structure with printer settings (`Uint8Array`).
|
|
696
|
+
|
|
697
|
+
- `outputSettings` Save for Web output settings, raw descriptor object (with `_name` and `_classID` fields), written back unchanged.
|
|
698
|
+
|
|
699
|
+
- `colorHalftoneScreens`, `grayscaleHalftoneScreens`, `colorTransferFunctions` and `grayscaleTransferFunctions` halftone screens and transfer functions used for printing.
|
|
700
|
+
|
|
701
|
+
- `printInformation`, `printScale`, `printFlags`, `printFlagsInfo` and `printStyle` Specifies options for printing the document.
|
|
702
|
+
|
|
703
|
+
- `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.
|
|
704
|
+
|
|
705
|
+
- `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.
|
|
706
|
+
|
|
707
|
+
- `colorSamplers` positions (in pixels), color spaces and sample size (`depth`) of color samplers. Samplers are written in Photoshop CS3 format if any of them has `depth` set, otherwise Photoshop 5 format is used.
|
|
708
|
+
|
|
709
|
+
- `quickMaskInfo` channel id and "initially empty" flag of Quick Mask.
|
|
710
|
+
|
|
711
|
+
- `measurementScale` measurement scale settings (raw descriptor data, `Uint8Array`).
|
|
712
|
+
|
|
713
|
+
- `duotoneHalftoneScreens`, `duotoneTransferFunctions`, `duotoneImageInformation` (raw data) and `alternateDuotoneColors` (Lab equivalents of duotone inks) settings of "Duotone" documents.
|
|
714
|
+
|
|
715
|
+
- `effectsVisible` global flag to show or hide all layer effects (Photoshop only writes it when effects are hidden).
|
|
716
|
+
|
|
717
|
+
- `layerComps` list of layer comps defined in the document, per-layer settings are stored in `comps` field of each layer.
|
|
718
|
+
|
|
719
|
+
- `animations`, `onionSkins`, `timelineInformation` and `sheetDisclosure` frame animation and video timeline settings.
|
|
720
|
+
|
|
721
|
+
- `slices` list of slices defined in the document.
|
|
722
|
+
|
|
723
|
+
- `countInformation` data of the Count tool.
|
|
724
|
+
|
|
725
|
+
- `copyrighted` and `url` copyright status and URL from File Info dialog.
|
|
726
|
+
|
|
727
|
+
- `layerState` index of the target (active) layer, `0` is the bottom layer.
|
|
728
|
+
|
|
729
|
+
- `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.
|
|
730
|
+
|
|
731
|
+
- `alphaIdentifiers` unique identifiers of alpha channels, in the same order as `alphaChannelNames`.
|
|
732
|
+
|
|
733
|
+
- `globalAngle` and `globalAltitude` global light angle (in degrees) and altitude (in degrees) used by layer effects with `useGlobalLight` option enabled.
|
|
734
|
+
|
|
735
|
+
- `urlsList` list of URLs assigned to slices, `id` is the id of the slice (`ref` is always `'slice'`).
|
|
736
|
+
|
|
737
|
+
- `captionDigest` MD5 digest of the IPTC data (`iptcData`), as 32 character hex string.
|
|
738
|
+
|
|
739
|
+
- `backgroundColor` background color of the color picker (tools panel) at the time the document was saved.
|
|
740
|
+
|
|
741
|
+
- `idsSeedNumber` base value that new layer IDs are generated from (Photoshop uses higher value if existing IDs already exceed it).
|
|
742
|
+
|
|
743
|
+
- `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.
|
|
744
|
+
|
|
745
|
+
- `savedPaths` saved paths from the Paths panel. Path data uses the same structure as layer `vectorMask` (points are in document pixels):
|
|
746
|
+
|
|
747
|
+
```ts
|
|
748
|
+
type SavedPath = {
|
|
749
|
+
name: string;
|
|
750
|
+
symmetryMode?: string; // raw enum value from paths with symmetry, e.g. 'pathSymmetryModeBasicPath'
|
|
751
|
+
fillStartsWithAllPixels?: boolean;
|
|
752
|
+
clipboard?: { top: number; left: number; bottom: number; right: number; resolution: number; };
|
|
753
|
+
paths: BezierPath[];
|
|
754
|
+
vectorOrigination?: { keyDescriptorList: KeyDescriptorItem[]; }; // live shape properties, same as layer `vectorOrigination`
|
|
755
|
+
};
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
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).
|
|
759
|
+
|
|
760
|
+
- `workPath` temporary "Work Path" from the Paths panel, same structure as saved path without `name`.
|
|
761
|
+
|
|
762
|
+
- `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).
|
|
763
|
+
|
|
764
|
+
- `imageReadyVariables` and `imageReadyDataSets` XML of variables and data sets (Image > Variables), stored as raw strings.
|
|
613
765
|
|
|
614
766
|
## Smart Objects
|
|
615
767
|
|
|
@@ -617,32 +769,55 @@ Layers with `placedLayer` property are smart object layers. `placedLayer` proper
|
|
|
617
769
|
|
|
618
770
|
```ts
|
|
619
771
|
interface PlacedLayer {
|
|
620
|
-
id: string; // id of linked image file (psd.linkedFiles)
|
|
772
|
+
id: string; // id of linked image file (psd.linkedFiles), must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
|
|
621
773
|
placed?: string; // unique id
|
|
622
774
|
type: PlacedLayerType;
|
|
775
|
+
external?: boolean; // linked smart object (linked file is stored outside of the document)
|
|
776
|
+
pageNumber?: number;
|
|
777
|
+
totalPages?: number;
|
|
778
|
+
frameStep?: { numerator: number; denominator: number; };
|
|
779
|
+
duration?: { numerator: number; denominator: number; };
|
|
780
|
+
frameCount?: number;
|
|
623
781
|
transform: number[]; // x, y of 4 corners of the transform
|
|
624
782
|
nonAffineTransform?: number[]; // x, y of 4 corners of the transform
|
|
625
|
-
width?: number;
|
|
626
|
-
height?: number;
|
|
783
|
+
width?: number; // width of the linked image
|
|
784
|
+
height?: number; // height of the linked image
|
|
627
785
|
resolution?: UnitsValue;
|
|
628
|
-
warp?: Warp;
|
|
786
|
+
warp?: Warp; // warp coordinates are relative to the linked image size
|
|
629
787
|
crop?: number;
|
|
788
|
+
comp?: number;
|
|
789
|
+
compInfo?: { compID: number; originalCompID: number; };
|
|
790
|
+
filter?: PlacedLayerFilter; // smart filters
|
|
630
791
|
}
|
|
631
792
|
```
|
|
632
793
|
|
|
794
|
+
Smart filters that are not supported by this library are skipped when reading (an error is thrown instead if `throwForMissingFeatures` option is set).
|
|
795
|
+
|
|
633
796
|
The Psd object has `linkedFiles` property, that specifies list of all files linked in smart objects. Each linked file has following structure:
|
|
634
797
|
|
|
635
798
|
```ts
|
|
636
799
|
interface LinkedFile {
|
|
637
|
-
id: string;
|
|
800
|
+
id: string; // must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)
|
|
638
801
|
name: string;
|
|
639
802
|
type?: string;
|
|
640
803
|
creator?: string;
|
|
641
804
|
data?: Uint8Array;
|
|
642
|
-
time?:
|
|
805
|
+
time?: string; // for external files, date in ISO format
|
|
806
|
+
descriptor?: {
|
|
807
|
+
compInfo: { compID: number; originalCompID: number; };
|
|
808
|
+
};
|
|
643
809
|
childDocumentID?: string;
|
|
644
810
|
assetModTime?: number;
|
|
645
811
|
assetLockedState?: number;
|
|
812
|
+
|
|
813
|
+
// external files
|
|
814
|
+
linkedFile?: {
|
|
815
|
+
fileSize: number;
|
|
816
|
+
name: string;
|
|
817
|
+
fullPath: string;
|
|
818
|
+
originalPath: string;
|
|
819
|
+
relativePath: string;
|
|
820
|
+
};
|
|
646
821
|
}
|
|
647
822
|
```
|
|
648
823
|
|
|
@@ -674,7 +849,7 @@ interface LinkedFile {
|
|
|
674
849
|
psd.linkedFiles = [
|
|
675
850
|
{
|
|
676
851
|
"id": "20953ddb-9391-11ec-b4f1-c15674f50bc4",
|
|
677
|
-
"name": "cat.png"
|
|
852
|
+
"name": "cat.png",
|
|
678
853
|
"data": fileContentsAsUint8Array,
|
|
679
854
|
}
|
|
680
855
|
];
|
|
@@ -682,7 +857,7 @@ interface LinkedFile {
|
|
|
682
857
|
|
|
683
858
|
## Units value
|
|
684
859
|
|
|
685
|
-
Some fields in the PSD document
|
|
860
|
+
Some fields in the PSD document specify a value with units, those fields use `UnitsValue` type:
|
|
686
861
|
|
|
687
862
|
```ts
|
|
688
863
|
interface UnitsValue {
|
|
@@ -707,14 +882,16 @@ Many fields in PSD file support passing color in different color formats (RGBA,
|
|
|
707
882
|
```ts
|
|
708
883
|
type RGBA = { r: number; g: number; b: number; a: number; }; // values from 0 to 255
|
|
709
884
|
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)
|
|
885
|
+
type FRGB = { fr: number; fg: number; fb: number; }; // values from 0 to 1 (can be above 1, can be negative)
|
|
711
886
|
type HSB = { h: number; s: number; b: number; }; // values from 0 to 1
|
|
712
887
|
type CMYK = { c: number; m: number; y: number; k: number; }; // values from 0 to 255
|
|
713
888
|
type LAB = { l: number; a: number; b: number; }; // values `l` from 0 to 1; `a` and `b` from -1 to 1
|
|
714
889
|
type Grayscale = { k: number }; // values from 0 to 255
|
|
715
|
-
type Color = RGBA | RGB | FRGB | HSB | CMYK | LAB | Grayscale;
|
|
890
|
+
type Color = (RGBA | RGB | FRGB | HSB | CMYK | LAB | Grayscale) & { book?: ColorBookInfo; };
|
|
716
891
|
```
|
|
717
892
|
|
|
893
|
+
Colors picked from color books (Pantone, etc.) also have `book` field with name of the book and the color (`{ book: string; name: string; bookID: number; bookKey: string; }`), color values hold the book color converted to document color space.
|
|
894
|
+
|
|
718
895
|
When you want to set field with a `Color` type, it's pretty straightforward, you can just choose any of the formats you like and set it on the field:
|
|
719
896
|
|
|
720
897
|
```ts
|
|
@@ -734,7 +911,7 @@ if ('l' in color) {
|
|
|
734
911
|
// color is Grayscale
|
|
735
912
|
} else if ('a' in color) {
|
|
736
913
|
// color is RGBA
|
|
737
|
-
} else if ('
|
|
914
|
+
} else if ('fr' in color) {
|
|
738
915
|
// color is FRGB
|
|
739
916
|
} else {
|
|
740
917
|
// color is RGB
|