ag-psd 16.0.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/psdWriter.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  offsetForChannel, createImageData, fromBlendMode, ChannelID, Compression, clamp,
5
5
  LayerMaskFlags, MaskParams, ColorSpace, Bounds, largeAdditionalInfoKeys, RAW_IMAGE_DATA, writeDataZipWithoutPrediction
6
6
  } from './helpers';
7
- import { ExtendedWriteOptions, hasMultiEffects, infoHandlers } from './additionalInfo';
7
+ import { ExtendedWriteOptions, infoHandlers } from './additionalInfo';
8
8
  import { resourceHandlers } from './imageResources';
9
9
 
10
10
  export interface PsdWriter {
@@ -43,11 +43,21 @@ export function writeUint16(writer: PsdWriter, value: number) {
43
43
  writer.view.setUint16(offset, value, false);
44
44
  }
45
45
 
46
+ export function writeUint16LE(writer: PsdWriter, value: number) {
47
+ const offset = addSize(writer, 2);
48
+ writer.view.setUint16(offset, value, true);
49
+ }
50
+
46
51
  export function writeInt32(writer: PsdWriter, value: number) {
47
52
  const offset = addSize(writer, 4);
48
53
  writer.view.setInt32(offset, value, false);
49
54
  }
50
55
 
56
+ export function writeInt32LE(writer: PsdWriter, value: number) {
57
+ const offset = addSize(writer, 4);
58
+ writer.view.setInt32(offset, value, true);
59
+ }
60
+
51
61
  export function writeUint32(writer: PsdWriter, value: number) {
52
62
  const offset = addSize(writer, 4);
53
63
  writer.view.setUint32(offset, value, false);
@@ -110,14 +120,23 @@ export function writePascalString(writer: PsdWriter, text: string, padTo: number
110
120
  }
111
121
  }
112
122
 
113
- export function writeUnicodeString(writer: PsdWriter, text: string) {
114
- writeUint32(writer, text.length);
115
-
123
+ export function writeUnicodeStringWithoutLength(writer: PsdWriter, text: string) {
116
124
  for (let i = 0; i < text.length; i++) {
117
125
  writeUint16(writer, text.charCodeAt(i));
118
126
  }
119
127
  }
120
128
 
129
+ export function writeUnicodeStringWithoutLengthLE(writer: PsdWriter, text: string) {
130
+ for (let i = 0; i < text.length; i++) {
131
+ writeUint16LE(writer, text.charCodeAt(i));
132
+ }
133
+ }
134
+
135
+ export function writeUnicodeString(writer: PsdWriter, text: string) {
136
+ writeUint32(writer, text.length);
137
+ writeUnicodeStringWithoutLength(writer, text);
138
+ }
139
+
121
140
  export function writeUnicodeStringWithPadding(writer: PsdWriter, text: string) {
122
141
  writeUint32(writer, text.length + 1);
123
142
 
@@ -304,10 +323,7 @@ function writeLayerInfo(tempBuffer: Uint8Array, writer: PsdWriter, psd: Psd, glo
304
323
  if (layer.vectorMask || (layer.sectionDivider && layer.sectionDivider.type !== SectionDividerType.Other)) {
305
324
  flags |= 0x10; // pixel data irrelevant to appearance of document
306
325
  }
307
- if (layer.effects && hasMultiEffects(layer.effects)) { // TODO: this is not correct
308
- flags |= 0x20; // just guessing this one, might be completely incorrect
309
- }
310
- // if ('_2' in layer) flags |= 0x20; // TEMP!!!
326
+ if (layer.effectsOpen) flags |= 0x20;
311
327
 
312
328
  writeUint8(writer, flags);
313
329
  writeUint8(writer, 0); // filler