psd 3.4.0 → 4.1.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 (216) hide show
  1. package/README.md +196 -149
  2. package/dist/descriptor.d.ts +20 -0
  3. package/dist/descriptor.d.ts.map +1 -0
  4. package/dist/descriptor.js +114 -0
  5. package/dist/descriptor.js.map +1 -0
  6. package/dist/engine-data.d.ts +11 -0
  7. package/dist/engine-data.d.ts.map +1 -0
  8. package/dist/engine-data.js +82 -0
  9. package/dist/engine-data.js.map +1 -0
  10. package/dist/image.d.ts +52 -0
  11. package/dist/image.d.ts.map +1 -0
  12. package/dist/image.js +301 -0
  13. package/dist/image.js.map +1 -0
  14. package/dist/index.d.ts +16 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +10 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/layer-info.d.ts +494 -0
  19. package/dist/layer-info.d.ts.map +1 -0
  20. package/dist/layer-info.js +529 -0
  21. package/dist/layer-info.js.map +1 -0
  22. package/dist/layer-styles.d.ts +160 -0
  23. package/dist/layer-styles.d.ts.map +1 -0
  24. package/dist/layer-styles.js +183 -0
  25. package/dist/layer-styles.js.map +1 -0
  26. package/dist/layer.d.ts +143 -0
  27. package/dist/layer.d.ts.map +1 -0
  28. package/dist/layer.js +249 -0
  29. package/dist/layer.js.map +1 -0
  30. package/dist/nodes.d.ts +233 -0
  31. package/dist/nodes.d.ts.map +1 -0
  32. package/dist/nodes.js +326 -0
  33. package/dist/nodes.js.map +1 -0
  34. package/dist/path-record.d.ts +34 -0
  35. package/dist/path-record.d.ts.map +1 -0
  36. package/dist/path-record.js +44 -0
  37. package/dist/path-record.js.map +1 -0
  38. package/dist/png.d.ts +10 -0
  39. package/dist/png.d.ts.map +1 -0
  40. package/dist/png.js +85 -0
  41. package/dist/png.js.map +1 -0
  42. package/dist/psd.d.ts +49 -0
  43. package/dist/psd.d.ts.map +1 -0
  44. package/dist/psd.js +106 -0
  45. package/dist/psd.js.map +1 -0
  46. package/dist/reader.d.ts +41 -0
  47. package/dist/reader.d.ts.map +1 -0
  48. package/dist/reader.js +100 -0
  49. package/dist/reader.js.map +1 -0
  50. package/dist/resources.d.ts +105 -0
  51. package/dist/resources.d.ts.map +1 -0
  52. package/dist/resources.js +173 -0
  53. package/dist/resources.js.map +1 -0
  54. package/dist/type-tool.d.ts +142 -0
  55. package/dist/type-tool.d.ts.map +1 -0
  56. package/dist/type-tool.js +222 -0
  57. package/dist/type-tool.js.map +1 -0
  58. package/package.json +26 -32
  59. package/src/descriptor.ts +141 -0
  60. package/src/engine-data.ts +86 -0
  61. package/src/image.ts +338 -0
  62. package/src/index.ts +38 -0
  63. package/src/layer-info.ts +578 -0
  64. package/src/layer-styles.ts +339 -0
  65. package/src/layer.ts +334 -0
  66. package/src/nodes.ts +411 -0
  67. package/src/path-record.ts +69 -0
  68. package/src/png.ts +92 -0
  69. package/src/psd.ts +133 -0
  70. package/src/reader.ts +125 -0
  71. package/src/resources.ts +273 -0
  72. package/src/type-tool.ts +270 -0
  73. package/.travis.yml +0 -5
  74. package/Cakefile +0 -61
  75. package/DEVELOPMENT.md +0 -27
  76. package/bower.json +0 -26
  77. package/docs/docco.css +0 -284
  78. package/docs/lib/psd/blend_mode.coffee.html +0 -72
  79. package/docs/lib/psd/channel_image.coffee.html +0 -81
  80. package/docs/lib/psd/color.coffee.html +0 -13
  81. package/docs/lib/psd/descriptor.coffee.html +0 -173
  82. package/docs/lib/psd/file.coffee.html +0 -78
  83. package/docs/lib/psd/header.coffee.html +0 -71
  84. package/docs/lib/psd/image.coffee.html +0 -94
  85. package/docs/lib/psd/image_export.coffee.html +0 -5
  86. package/docs/lib/psd/image_exports/png.coffee.html +0 -19
  87. package/docs/lib/psd/image_format.coffee.html +0 -8
  88. package/docs/lib/psd/image_formats/layer_raw.coffee.html +0 -9
  89. package/docs/lib/psd/image_formats/layer_rle.coffee.html +0 -10
  90. package/docs/lib/psd/image_formats/raw.coffee.html +0 -6
  91. package/docs/lib/psd/image_formats/rle.coffee.html +0 -37
  92. package/docs/lib/psd/image_mode.coffee.html +0 -7
  93. package/docs/lib/psd/image_modes/cmyk.coffee.html +0 -36
  94. package/docs/lib/psd/image_modes/greyscale.coffee.html +0 -17
  95. package/docs/lib/psd/image_modes/rgb.coffee.html +0 -32
  96. package/docs/lib/psd/init.coffee.html +0 -22
  97. package/docs/lib/psd/layer/blend_modes.coffee.html +0 -22
  98. package/docs/lib/psd/layer/blending_ranges.coffee.html +0 -29
  99. package/docs/lib/psd/layer/channel_image.coffee.html +0 -13
  100. package/docs/lib/psd/layer/helpers.coffee.html +0 -19
  101. package/docs/lib/psd/layer/info.coffee.html +0 -69
  102. package/docs/lib/psd/layer/mask.coffee.html +0 -11
  103. package/docs/lib/psd/layer/name.coffee.html +0 -15
  104. package/docs/lib/psd/layer/position_channels.coffee.html +0 -24
  105. package/docs/lib/psd/layer.coffee.html +0 -64
  106. package/docs/lib/psd/layer_info/blend_clipping_elements.coffee.html +0 -11
  107. package/docs/lib/psd/layer_info/blend_interior_elements.coffee.html +0 -11
  108. package/docs/lib/psd/layer_info/fill_opacity.coffee.html +0 -10
  109. package/docs/lib/psd/layer_info/gradient_fill.coffee.html +0 -12
  110. package/docs/lib/psd/layer_info/layer_id.coffee.html +0 -10
  111. package/docs/lib/psd/layer_info/layer_name_source.coffee.html +0 -10
  112. package/docs/lib/psd/layer_info/legacy_typetool.coffee.html +0 -82
  113. package/docs/lib/psd/layer_info/locked.coffee.html +0 -24
  114. package/docs/lib/psd/layer_info/metadata.coffee.html +0 -30
  115. package/docs/lib/psd/layer_info/nested_section_divider.coffee.html +0 -23
  116. package/docs/lib/psd/layer_info/object_effects.coffee.html +0 -12
  117. package/docs/lib/psd/layer_info/section_divider.coffee.html +0 -41
  118. package/docs/lib/psd/layer_info/solid_color.coffee.html +0 -24
  119. package/docs/lib/psd/layer_info/typetool.coffee.html +0 -121
  120. package/docs/lib/psd/layer_info/unicode_name.coffee.html +0 -14
  121. package/docs/lib/psd/layer_info/vector_mask.coffee.html +0 -37
  122. package/docs/lib/psd/layer_info/vector_origination.coffee.html +0 -12
  123. package/docs/lib/psd/layer_info/vector_stroke.coffee.html +0 -12
  124. package/docs/lib/psd/layer_info/vector_stroke_content.coffee.html +0 -12
  125. package/docs/lib/psd/layer_info.coffee.html +0 -11
  126. package/docs/lib/psd/layer_mask.coffee.html +0 -73
  127. package/docs/lib/psd/lazy_execute.coffee.html +0 -80
  128. package/docs/lib/psd/mask.coffee.html +0 -47
  129. package/docs/lib/psd/node.coffee.html +0 -100
  130. package/docs/lib/psd/nodes/ancestry.coffee.html +0 -47
  131. package/docs/lib/psd/nodes/build_preview.coffee.html +0 -6
  132. package/docs/lib/psd/nodes/group.coffee.html +0 -19
  133. package/docs/lib/psd/nodes/layer.coffee.html +0 -17
  134. package/docs/lib/psd/nodes/root.coffee.html +0 -61
  135. package/docs/lib/psd/nodes/search.coffee.html +0 -23
  136. package/docs/lib/psd/path_record.coffee.html +0 -73
  137. package/docs/lib/psd/resource.coffee.html +0 -20
  138. package/docs/lib/psd/resource_section.coffee.html +0 -16
  139. package/docs/lib/psd/resources/layer_comps.coffee.html +0 -31
  140. package/docs/lib/psd/resources.coffee.html +0 -44
  141. package/docs/lib/psd/util.coffee.html +0 -24
  142. package/docs/lib/psd.coffee.html +0 -85
  143. package/index.js +0 -2
  144. package/lib/psd/blend_mode.coffee +0 -78
  145. package/lib/psd/channel_image.coffee +0 -87
  146. package/lib/psd/color.coffee +0 -10
  147. package/lib/psd/descriptor.coffee +0 -189
  148. package/lib/psd/file.coffee +0 -88
  149. package/lib/psd/header.coffee +0 -83
  150. package/lib/psd/image.coffee +0 -107
  151. package/lib/psd/image_export.coffee +0 -2
  152. package/lib/psd/image_exports/png.coffee +0 -28
  153. package/lib/psd/image_format.coffee +0 -5
  154. package/lib/psd/image_formats/layer_raw.coffee +0 -6
  155. package/lib/psd/image_formats/layer_rle.coffee +0 -7
  156. package/lib/psd/image_formats/raw.coffee +0 -3
  157. package/lib/psd/image_formats/rle.coffee +0 -38
  158. package/lib/psd/image_mode.coffee +0 -4
  159. package/lib/psd/image_modes/cmyk.coffee +0 -36
  160. package/lib/psd/image_modes/greyscale.coffee +0 -14
  161. package/lib/psd/image_modes/rgb.coffee +0 -39
  162. package/lib/psd/init.coffee +0 -21
  163. package/lib/psd/layer/blend_modes.coffee +0 -20
  164. package/lib/psd/layer/blending_ranges.coffee +0 -28
  165. package/lib/psd/layer/channel_image.coffee +0 -10
  166. package/lib/psd/layer/helpers.coffee +0 -16
  167. package/lib/psd/layer/info.coffee +0 -76
  168. package/lib/psd/layer/mask.coffee +0 -8
  169. package/lib/psd/layer/name.coffee +0 -12
  170. package/lib/psd/layer/position_channels.coffee +0 -22
  171. package/lib/psd/layer.coffee +0 -64
  172. package/lib/psd/layer_info/artboard.coffee +0 -16
  173. package/lib/psd/layer_info/blend_clipping_elements.coffee +0 -8
  174. package/lib/psd/layer_info/blend_interior_elements.coffee +0 -8
  175. package/lib/psd/layer_info/fill_opacity.coffee +0 -7
  176. package/lib/psd/layer_info/gradient_fill.coffee +0 -9
  177. package/lib/psd/layer_info/layer_id.coffee +0 -7
  178. package/lib/psd/layer_info/layer_name_source.coffee +0 -7
  179. package/lib/psd/layer_info/legacy_typetool.coffee +0 -80
  180. package/lib/psd/layer_info/locked.coffee +0 -21
  181. package/lib/psd/layer_info/metadata.coffee +0 -27
  182. package/lib/psd/layer_info/nested_section_divider.coffee +0 -22
  183. package/lib/psd/layer_info/object_effects.coffee +0 -9
  184. package/lib/psd/layer_info/section_divider.coffee +0 -38
  185. package/lib/psd/layer_info/solid_color.coffee +0 -21
  186. package/lib/psd/layer_info/typetool.coffee +0 -172
  187. package/lib/psd/layer_info/unicode_name.coffee +0 -11
  188. package/lib/psd/layer_info/vector_mask.coffee +0 -35
  189. package/lib/psd/layer_info/vector_origination.coffee +0 -9
  190. package/lib/psd/layer_info/vector_stroke.coffee +0 -9
  191. package/lib/psd/layer_info/vector_stroke_content.coffee +0 -9
  192. package/lib/psd/layer_info.coffee +0 -8
  193. package/lib/psd/layer_mask.coffee +0 -73
  194. package/lib/psd/lazy_execute.coffee +0 -86
  195. package/lib/psd/mask.coffee +0 -52
  196. package/lib/psd/node.coffee +0 -150
  197. package/lib/psd/nodes/ancestry.coffee +0 -44
  198. package/lib/psd/nodes/build_preview.coffee +0 -3
  199. package/lib/psd/nodes/group.coffee +0 -16
  200. package/lib/psd/nodes/layer.coffee +0 -14
  201. package/lib/psd/nodes/root.coffee +0 -59
  202. package/lib/psd/nodes/search.coffee +0 -20
  203. package/lib/psd/path_record.coffee +0 -72
  204. package/lib/psd/resource.coffee +0 -17
  205. package/lib/psd/resource_section.coffee +0 -16
  206. package/lib/psd/resources/guides.coffee +0 -25
  207. package/lib/psd/resources/layer_comps.coffee +0 -28
  208. package/lib/psd/resources/layer_links.coffee +0 -17
  209. package/lib/psd/resources/resolution_info.coffee +0 -26
  210. package/lib/psd/resources.coffee +0 -41
  211. package/lib/psd/util.coffee +0 -23
  212. package/lib/psd.coffee +0 -92
  213. package/output/Logo_Glyph.png +0 -0
  214. package/output/Make a change and save..png +0 -0
  215. package/output/Matte.png +0 -0
  216. package/webpack.config.js +0 -23
package/dist/psd.js ADDED
@@ -0,0 +1,106 @@
1
+ import { CompositeImage } from './image.js';
2
+ import { readLayerSection } from './layer.js';
3
+ import { RootNode } from './nodes.js';
4
+ import { Reader } from './reader.js';
5
+ import { Resources } from './resources.js';
6
+ const MODES = [
7
+ 'Bitmap',
8
+ 'GrayScale',
9
+ 'IndexedColor',
10
+ 'RGBColor',
11
+ 'CMYKColor',
12
+ 'HSLColor',
13
+ 'HSBColor',
14
+ 'Multichannel',
15
+ 'Duotone',
16
+ 'LabColor',
17
+ 'Gray16',
18
+ 'RGB48',
19
+ 'Lab48',
20
+ 'CMYK64',
21
+ 'DeepMultichannel',
22
+ 'Duotone16',
23
+ ];
24
+ function readHeader(r) {
25
+ const signature = r.ascii(4);
26
+ if (signature !== '8BPS')
27
+ throw new Error(`Invalid file signature '${signature}', expected '8BPS'`);
28
+ const version = r.uint16();
29
+ if (version !== 1 && version !== 2)
30
+ throw new Error(`Unsupported PSD version ${version}`);
31
+ r.skip(6); // reserved
32
+ const channels = r.uint16();
33
+ const height = r.uint32();
34
+ const width = r.uint32();
35
+ const depth = r.uint16();
36
+ const mode = r.uint16();
37
+ const colorModeData = r.bytesView(r.uint32());
38
+ return { version, isBig: version === 2, channels, width, height, depth, mode, modeName: MODES[mode] ?? 'Unknown', colorModeData };
39
+ }
40
+ /**
41
+ * A Photoshop document (PSD or PSB). Construction only reads the header and locates each
42
+ * section; everything else is parsed on first access.
43
+ *
44
+ * ```ts
45
+ * const psd = new PSD(await readFile('file.psd'));
46
+ * console.log(psd.tree.toJSON());
47
+ * ```
48
+ */
49
+ export class PSD {
50
+ header;
51
+ #reader;
52
+ #resourcesOffset;
53
+ #layersOffset;
54
+ #imageOffset;
55
+ #resources;
56
+ #layerSection;
57
+ #image;
58
+ #tree;
59
+ constructor(data) {
60
+ const bytes = ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
61
+ const r = new Reader(bytes);
62
+ this.#reader = r;
63
+ this.header = readHeader(r);
64
+ this.#resourcesOffset = r.pos;
65
+ r.skip(r.uint32());
66
+ this.#layersOffset = r.pos;
67
+ r.skip(this.header.isBig ? r.int64() : r.uint32());
68
+ this.#imageOffset = r.pos;
69
+ if (this.#imageOffset > bytes.length)
70
+ throw new Error('File is truncated');
71
+ }
72
+ get width() {
73
+ return this.header.width;
74
+ }
75
+ get height() {
76
+ return this.header.height;
77
+ }
78
+ /** Image resources: layer comps, guides, slices, resolution and more. */
79
+ get resources() {
80
+ if (!this.#resources) {
81
+ const r = this.#reader.at(this.#resourcesOffset);
82
+ const length = r.uint32();
83
+ this.#resources = new Resources(r, r.pos + length);
84
+ }
85
+ return this.#resources;
86
+ }
87
+ get #layers() {
88
+ return (this.#layerSection ??= readLayerSection(this.#reader.at(this.#layersOffset), this.header, () => this.resources));
89
+ }
90
+ /** Every layer record from top to bottom, including group dividers. Use `tree` for the hierarchy. */
91
+ get layers() {
92
+ return this.#layers.layers;
93
+ }
94
+ get globalMask() {
95
+ return this.#layers.globalMask;
96
+ }
97
+ /** The flattened composite image. */
98
+ get image() {
99
+ return (this.#image ??= new CompositeImage(this.#reader.at(this.#imageOffset), this.header, () => this.resources));
100
+ }
101
+ /** The document as a tree of groups and layers. */
102
+ get tree() {
103
+ return (this.#tree ??= new RootNode(this));
104
+ }
105
+ }
106
+ //# sourceMappingURL=psd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psd.js","sourceRoot":"","sources":["../src/psd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAkD,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,KAAK,GAAG;IACZ,QAAQ;IACR,WAAW;IACX,cAAc;IACd,UAAU;IACV,WAAW;IACX,UAAU;IACV,UAAU;IACV,cAAc;IACd,SAAS;IACT,UAAU;IACV,QAAQ;IACR,OAAO;IACP,OAAO;IACP,QAAQ;IACR,kBAAkB;IAClB,WAAW;CACH,CAAC;AAoBX,SAAS,UAAU,CAAC,CAAS;IAC3B,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,SAAS,KAAK,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,oBAAoB,CAAC,CAAC;IACpG,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,IAAI,OAAO,KAAK,CAAC,IAAI,OAAO,KAA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O,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3H,CAAC;IAED,qGAAqG;IACrG,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,qCAAqC;IACrC,IAAI,KAAK;QACP,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACrH,CAAC;IAED,mDAAmD;IACnD,IAAI,IAAI;QACN,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ /** A big-endian cursor over the PSD bytes. Cheap to create, so lazy sections each get their own. */
2
+ export declare class Reader {
3
+ readonly bytes: Uint8Array;
4
+ readonly view: DataView;
5
+ pos: number;
6
+ constructor(bytes: Uint8Array, pos?: number);
7
+ /** A new reader over the same bytes, positioned at `pos`. */
8
+ at(pos: number): Reader;
9
+ seek(pos: number): void;
10
+ skip(n: number): void;
11
+ uint8(): number;
12
+ int8(): number;
13
+ bool(): boolean;
14
+ int16(): number;
15
+ uint16(): number;
16
+ int32(): number;
17
+ uint32(): number;
18
+ /** 64-bit integer as a Number. Exact up to 2^53, which covers any real file offset. */
19
+ int64(): number;
20
+ float32(): number;
21
+ float64(): number;
22
+ /** A zero-copy view of the next `n` bytes. */
23
+ bytesView(n: number): Uint8Array;
24
+ /** A single-byte (Latin-1) string with NUL characters removed. */
25
+ ascii(n: number): string;
26
+ /** A Pascal string: a length byte followed by that many characters. */
27
+ pascal(): string;
28
+ /** A UTF-16BE string of `length` code units, read from a leading uint32 when omitted. */
29
+ unicode(length?: number): string;
30
+ /** Signed 8.24 fixed-point number used by path records. */
31
+ pathNumber(): number;
32
+ /** A color space ID followed by four 16-bit components (reduced to 8 bits). */
33
+ spaceColor(): SpaceColor;
34
+ }
35
+ export interface SpaceColor {
36
+ colorSpace: number;
37
+ components: number[];
38
+ }
39
+ /** Rounds up to an even number. */
40
+ export declare const pad2: (n: number) => number;
41
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAEA,oGAAoG;AACpG,qBAAa,MAAM;IACjB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IAEZ,YAAY,KAAK,EAAE,UAAU,EAAE,GAAG,SAAI,EAIrC;IAED,6DAA6D;IAC7D,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtB;IAED,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEtB;IAED,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAEpB;IAED,KAAK,IAAI,MAAM,CAEd;IAED,IAAI,IAAI,MAAM,CAEb;IAED,IAAI,IAAI,OAAO,CAEd;IAED,KAAK,IAAI,MAAM,CAId;IAED,MAAM,IAAI,MAAM,CAIf;IAED,KAAK,IAAI,MAAM,CAId;IAED,MAAM,IAAI,MAAM,CAIf;IAED,uFAAuF;IACvF,KAAK,IAAI,MAAM,CAId;IAED,OAAO,IAAI,MAAM,CAIhB;IAED,OAAO,IAAI,MAAM,CAIhB;IAED,8CAA8C;IAC9C,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAK/B;IAED,kEAAkE;IAClE,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEvB;IAED,uEAAuE;IACvE,MAAM,IAAI,MAAM,CAEf;IAED,yFAAyF;IACzF,OAAO,CAAC,MAAM,SAAgB,GAAG,MAAM,CAEtC;IAED,2DAA2D;IAC3D,UAAU,IAAI,MAAM,CAEnB;IAED,+EAA+E;IAC/E,UAAU,IAAI,UAAU,CAIvB;CACF;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,mCAAmC;AACnC,eAAO,MAAM,IAAI,MAAO,MAAM,WAAiB,CAAC"}
package/dist/reader.js ADDED
@@ -0,0 +1,100 @@
1
+ const utf16 = new TextDecoder('utf-16be');
2
+ /** A big-endian cursor over the PSD bytes. Cheap to create, so lazy sections each get their own. */
3
+ export class Reader {
4
+ bytes;
5
+ view;
6
+ pos;
7
+ constructor(bytes, pos = 0) {
8
+ this.bytes = bytes;
9
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
10
+ this.pos = pos;
11
+ }
12
+ /** A new reader over the same bytes, positioned at `pos`. */
13
+ at(pos) {
14
+ return new Reader(this.bytes, pos);
15
+ }
16
+ seek(pos) {
17
+ this.pos = pos;
18
+ }
19
+ skip(n) {
20
+ this.pos += n;
21
+ }
22
+ uint8() {
23
+ return this.view.getUint8(this.pos++);
24
+ }
25
+ int8() {
26
+ return this.view.getInt8(this.pos++);
27
+ }
28
+ bool() {
29
+ return this.uint8() !== 0;
30
+ }
31
+ int16() {
32
+ const v = this.view.getInt16(this.pos);
33
+ this.pos += 2;
34
+ return v;
35
+ }
36
+ uint16() {
37
+ const v = this.view.getUint16(this.pos);
38
+ this.pos += 2;
39
+ return v;
40
+ }
41
+ int32() {
42
+ const v = this.view.getInt32(this.pos);
43
+ this.pos += 4;
44
+ return v;
45
+ }
46
+ uint32() {
47
+ const v = this.view.getUint32(this.pos);
48
+ this.pos += 4;
49
+ return v;
50
+ }
51
+ /** 64-bit integer as a Number. Exact up to 2^53, which covers any real file offset. */
52
+ int64() {
53
+ const v = Number(this.view.getBigInt64(this.pos));
54
+ this.pos += 8;
55
+ return v;
56
+ }
57
+ float32() {
58
+ const v = this.view.getFloat32(this.pos);
59
+ this.pos += 4;
60
+ return v;
61
+ }
62
+ float64() {
63
+ const v = this.view.getFloat64(this.pos);
64
+ this.pos += 8;
65
+ return v;
66
+ }
67
+ /** A zero-copy view of the next `n` bytes. */
68
+ bytesView(n) {
69
+ if (this.pos + n > this.bytes.length)
70
+ throw new RangeError(`Read of ${n} bytes at ${this.pos} is out of bounds`);
71
+ const v = this.bytes.subarray(this.pos, this.pos + n);
72
+ this.pos += n;
73
+ return v;
74
+ }
75
+ /** A single-byte (Latin-1) string with NUL characters removed. */
76
+ ascii(n) {
77
+ return String.fromCharCode(...this.bytesView(n)).replaceAll('\0', '');
78
+ }
79
+ /** A Pascal string: a length byte followed by that many characters. */
80
+ pascal() {
81
+ return this.ascii(this.uint8());
82
+ }
83
+ /** A UTF-16BE string of `length` code units, read from a leading uint32 when omitted. */
84
+ unicode(length = this.uint32()) {
85
+ return utf16.decode(this.bytesView(length * 2)).replaceAll('\0', '');
86
+ }
87
+ /** Signed 8.24 fixed-point number used by path records. */
88
+ pathNumber() {
89
+ return this.int32() / (1 << 24);
90
+ }
91
+ /** A color space ID followed by four 16-bit components (reduced to 8 bits). */
92
+ spaceColor() {
93
+ const colorSpace = this.int16();
94
+ const components = [0, 0, 0, 0].map(() => this.uint16() >> 8);
95
+ return { colorSpace, components };
96
+ }
97
+ }
98
+ /** Rounds up to an even number. */
99
+ export const pad2 = (n) => (n + 1) & ~1;
100
+ //# sourceMappingURL=reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC;AAE1C,oGAAoG;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.ts';
2
+ import { Reader } from './reader.ts';
3
+ /** An image resource block. `offset` points at its data inside the file. */
4
+ export interface ResourceBlock {
5
+ id: number;
6
+ name: string;
7
+ offset: number;
8
+ size: number;
9
+ }
10
+ export interface LayerComp {
11
+ id: number;
12
+ name: string;
13
+ /** Bit flags: 1 = visibility, 2 = position, 4 = appearance. */
14
+ capturedInfo: number;
15
+ }
16
+ export interface Guide {
17
+ /** Position in pixels. */
18
+ location: number;
19
+ direction: 'horizontal' | 'vertical';
20
+ }
21
+ export interface ResolutionInfo {
22
+ /** Horizontal resolution in pixels per inch. `hResUnitName` is only the unit Photoshop displays it in. */
23
+ hRes: number;
24
+ hResUnit: number;
25
+ hResUnitName: string;
26
+ widthUnit: number;
27
+ widthUnitName: string;
28
+ vRes: number;
29
+ vResUnit: number;
30
+ vResUnitName: string;
31
+ heightUnit: number;
32
+ heightUnitName: string;
33
+ }
34
+ export interface Bounds {
35
+ top: number;
36
+ left: number;
37
+ bottom: number;
38
+ right: number;
39
+ }
40
+ /**
41
+ * A slice. Version 6 resources store `origin`, `type` and the alignments as numeric codes;
42
+ * versions 7+ store enum names such as `userGenerated` or `Img `.
43
+ */
44
+ export interface Slice {
45
+ id: number;
46
+ groupId: number;
47
+ origin: number | string;
48
+ /** Only stored by version 6 resources. */
49
+ associatedLayerId: number | null;
50
+ name: string;
51
+ type: number | string;
52
+ bounds: Bounds;
53
+ url: string;
54
+ target: string;
55
+ message: string;
56
+ alt: string;
57
+ cellTextIsHtml: boolean;
58
+ cellText: string;
59
+ horizontalAlignment: number | string;
60
+ verticalAlignment: number | string;
61
+ /** RGBA. Only stored by version 6 resources. */
62
+ color: [number, number, number, number] | null;
63
+ outset?: Bounds;
64
+ }
65
+ export interface Slices {
66
+ version: number;
67
+ name: string;
68
+ bounds: Bounds;
69
+ slices: Slice[];
70
+ }
71
+ export interface SavedPath {
72
+ id: number;
73
+ name: string;
74
+ records: PathRecord[];
75
+ }
76
+ /** The image resources section. Blocks are indexed up front and decoded on first access. */
77
+ export declare class Resources {
78
+ #private;
79
+ /** Every resource block in the file, by ID. */
80
+ readonly blocks: Map<number, ResourceBlock>;
81
+ constructor(r: Reader, end: number);
82
+ /** Raw bytes of a resource block. */
83
+ bytes(id: number): Uint8Array | undefined;
84
+ /** Resource 1065. */
85
+ get layerComps(): LayerComp[];
86
+ /** Resource 1032. */
87
+ get guides(): Guide[];
88
+ /** Resource 1005. */
89
+ get resolutionInfo(): ResolutionInfo | undefined;
90
+ /** Resource 1050, normalized to the same shape for every version. */
91
+ get slices(): Slices | undefined;
92
+ /** Resource 1060, the raw XMP packet. */
93
+ get xmpMetadata(): string | undefined;
94
+ /** Resource 1025. */
95
+ get workPath(): PathRecord[] | undefined;
96
+ /** Resources 2000-2997. */
97
+ get savedPaths(): SavedPath[];
98
+ /** Resource 1046: the number of colors in an indexed image's color table. */
99
+ get indexedColorCount(): number | undefined;
100
+ /** Resource 1047: the color table index that is transparent in an indexed image. */
101
+ get transparencyIndex(): number | undefined;
102
+ /** Resource 1026: the group ID of each layer, ordered top to bottom like `psd.layers`. */
103
+ get layerGroups(): number[] | undefined;
104
+ }
105
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAQ,MAAM,EAAE,MAAM,aAAa,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,K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 @@
1
+ import { readDescriptor } from './descriptor.js';
2
+ import { readPathRecords } from './path-record.js';
3
+ import { pad2, Reader } from './reader.js';
4
+ const RES_UNITS = ['pixel/inch', 'pixel/cm'];
5
+ const UNITS = ['in', 'cm', 'pt', 'picas', 'columns'];
6
+ const unitName = (names, unit) => names[unit - 1] ?? 'unknown';
7
+ /** The image resources section. Blocks are indexed up front and decoded on first access. */
8
+ export class Resources {
9
+ /** Every resource block in the file, by ID. */
10
+ blocks = new Map();
11
+ #reader;
12
+ #cache = new Map();
13
+ constructor(r, end) {
14
+ this.#reader = r;
15
+ while (r.pos < end) {
16
+ r.skip(4); // signature, 8BIM
17
+ const id = r.uint16();
18
+ const nameLength = pad2(r.uint8() + 1) - 1;
19
+ const name = r.ascii(nameLength);
20
+ const size = pad2(r.uint32());
21
+ this.blocks.set(id, { id, name, offset: r.pos, size });
22
+ r.skip(size);
23
+ }
24
+ }
25
+ /** Raw bytes of a resource block. */
26
+ bytes(id) {
27
+ const block = this.blocks.get(id);
28
+ return block && this.#reader.bytes.subarray(block.offset, block.offset + block.size);
29
+ }
30
+ #parse(id, parse) {
31
+ const key = String(id);
32
+ if (!this.#cache.has(key)) {
33
+ const block = this.blocks.get(id);
34
+ this.#cache.set(key, block && parse(this.#reader.at(block.offset), block));
35
+ }
36
+ return this.#cache.get(key);
37
+ }
38
+ /** Resource 1065. */
39
+ get layerComps() {
40
+ return (this.#parse(1065, (r) => {
41
+ r.skip(4); // descriptor version
42
+ const list = readDescriptor(r).list ?? [];
43
+ return list.map((c) => ({ id: c.compID, name: c['Nm '], capturedInfo: c.capturedInfo }));
44
+ }) ?? []);
45
+ }
46
+ /** Resource 1032. */
47
+ get guides() {
48
+ return (this.#parse(1032, (r) => {
49
+ r.skip(12); // version + future grid info
50
+ const count = r.int32();
51
+ return Array.from({ length: count }, () => ({
52
+ location: r.int32() / 32,
53
+ direction: r.uint8() === 0 ? 'vertical' : 'horizontal',
54
+ }));
55
+ }) ?? []);
56
+ }
57
+ /** Resource 1005. */
58
+ get resolutionInfo() {
59
+ return this.#parse(1005, (r) => {
60
+ const hRes = r.uint32() / 65536;
61
+ const hResUnit = r.uint16();
62
+ const widthUnit = r.uint16();
63
+ const vRes = r.uint32() / 65536;
64
+ const vResUnit = r.uint16();
65
+ const heightUnit = r.uint16();
66
+ return {
67
+ hRes,
68
+ hResUnit,
69
+ hResUnitName: unitName(RES_UNITS, hResUnit),
70
+ widthUnit,
71
+ widthUnitName: unitName(UNITS, widthUnit),
72
+ vRes,
73
+ vResUnit,
74
+ vResUnitName: unitName(RES_UNITS, vResUnit),
75
+ heightUnit,
76
+ heightUnitName: unitName(UNITS, heightUnit),
77
+ };
78
+ });
79
+ }
80
+ /** Resource 1050, normalized to the same shape for every version. */
81
+ get slices() {
82
+ return this.#parse(1050, readSlices);
83
+ }
84
+ /** Resource 1060, the raw XMP packet. */
85
+ get xmpMetadata() {
86
+ return this.#parse(1060, (r, block) => new TextDecoder().decode(r.bytesView(block.size)).replace(/\0+$/, ''));
87
+ }
88
+ /** Resource 1025. */
89
+ get workPath() {
90
+ return this.#parse(1025, (r, block) => readPathRecords(r, Math.floor(block.size / 26)));
91
+ }
92
+ /** Resources 2000-2997. */
93
+ get savedPaths() {
94
+ return [...this.blocks.values()]
95
+ .filter((b) => b.id >= 2000 && b.id <= 2997)
96
+ .map((b) => ({ id: b.id, name: b.name, records: this.#parse(b.id, (r) => readPathRecords(r, Math.floor(b.size / 26))) }));
97
+ }
98
+ /** Resource 1046: the number of colors in an indexed image's color table. */
99
+ get indexedColorCount() {
100
+ return this.#parse(1046, (r) => r.uint16());
101
+ }
102
+ /** Resource 1047: the color table index that is transparent in an indexed image. */
103
+ get transparencyIndex() {
104
+ return this.#parse(1047, (r) => r.uint16());
105
+ }
106
+ /** Resource 1026: the group ID of each layer, ordered top to bottom like `psd.layers`. */
107
+ get layerGroups() {
108
+ return this.#parse(1026, (r, block) => Array.from({ length: block.size / 2 }, () => r.uint16()).reverse());
109
+ }
110
+ }
111
+ function readSlices(r) {
112
+ const version = r.int32();
113
+ if (version === 6)
114
+ return readLegacySlices(r);
115
+ if (version !== 7 && version !== 8)
116
+ throw new Error(`Unsupported slices resource version ${version}`);
117
+ r.skip(4); // descriptor version
118
+ const d = readDescriptor(r);
119
+ const bounds = (b) => ({ top: b['Top '], left: b['Left'], bottom: b['Btom'], right: b['Rght'] });
120
+ return {
121
+ version,
122
+ name: d.baseName,
123
+ bounds: bounds(d.bounds),
124
+ slices: d.slices.map((s) => ({
125
+ id: s.sliceID,
126
+ groupId: s.groupID,
127
+ origin: s.origin.value,
128
+ associatedLayerId: null,
129
+ name: s['Nm '] ?? '',
130
+ type: s.Type.value,
131
+ bounds: bounds(s.bounds),
132
+ url: s.url ?? '',
133
+ target: s.null ?? '',
134
+ message: s.Msge ?? '',
135
+ alt: s.altTag ?? '',
136
+ cellTextIsHtml: s.cellTextIsHTML ?? false,
137
+ cellText: s.cellText ?? '',
138
+ horizontalAlignment: s.horzAlign.value,
139
+ verticalAlignment: s.vertAlign.value,
140
+ color: null,
141
+ outset: { top: s.topOutset, left: s.leftOutset, bottom: s.bottomOutset, right: s.rightOutset },
142
+ })),
143
+ };
144
+ }
145
+ function readLegacySlices(r) {
146
+ const bounds = { top: r.int32(), left: r.int32(), bottom: r.int32(), right: r.int32() };
147
+ const name = r.unicode();
148
+ const count = r.int32();
149
+ const slices = Array.from({ length: count }, () => {
150
+ const id = r.int32();
151
+ const groupId = r.int32();
152
+ const origin = r.int32();
153
+ const associatedLayerId = origin === 1 ? r.int32() : null;
154
+ const name = r.unicode();
155
+ const type = r.int32();
156
+ const bounds = { left: r.int32(), top: r.int32(), right: r.int32(), bottom: r.int32() };
157
+ const url = r.unicode();
158
+ const target = r.unicode();
159
+ const message = r.unicode();
160
+ const alt = r.unicode();
161
+ const cellTextIsHtml = r.bool();
162
+ const cellText = r.unicode();
163
+ const horizontalAlignment = r.int32();
164
+ const verticalAlignment = r.int32();
165
+ const [a, red, g, b] = [r.uint8(), r.uint8(), r.uint8(), r.uint8()];
166
+ return {
167
+ id, groupId, origin, associatedLayerId, name, type, bounds, url, target, message, alt,
168
+ cellTextIsHtml, cellText, horizontalAlignment, verticalAlignment, color: [red, g, b, a],
169
+ };
170
+ });
171
+ return { version: 6, name, bounds, slices };
172
+ }
173
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAmF3C,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAC7C,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;AACrD,MAAM,QAAQ,GAAG,CAAC,KAAe,EAAE,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC;AAEjF,4FAA4F;AAC5F,MAAM,OAAO,SAAS;IACpB,+CAA+C;IACtC,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC1C,OAAO,CAAS;IAChB,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE7C,YAAY,CAAS,EAAE,GAAW;QAChC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,OAAO,CAAC,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC;YACnB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB;YAC7B,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,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