ag-psd 32.0.0 → 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.
- 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/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/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/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 +78 -0
- package/LICENSE +5 -0
- package/README.md +3 -6
- package/README_PSD.md +242 -81
- package/dist/abr.d.ts +11 -4
- package/dist/abr.js +357 -230
- package/dist/abr.js.map +1 -1
- package/dist/additionalInfo.d.ts +54 -2
- package/dist/additionalInfo.js +487 -306
- 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 +1937 -1115
- package/dist/descriptor.d.ts +14 -8
- package/dist/descriptor.js +202 -186
- package/dist/descriptor.js.map +1 -1
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.js +4 -2
- package/dist/helpers.js.map +1 -1
- package/dist/imageResources.d.ts +15 -3
- package/dist/imageResources.js +503 -142
- package/dist/imageResources.js.map +1 -1
- package/dist/jpeg.js +8 -8
- package/dist/jpeg.js.map +1 -1
- package/dist/psd.d.ts +148 -17
- package/dist/psd.js.map +1 -1
- package/dist/psdReader.d.ts +10 -0
- package/dist/psdReader.js +278 -166
- package/dist/psdReader.js.map +1 -1
- package/dist/psdWriter.d.ts +1 -0
- package/dist/psdWriter.js +77 -62
- package/dist/psdWriter.js.map +1 -1
- package/dist/text.js +17 -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 +357 -230
- package/dist-es/abr.js.map +1 -1
- package/dist-es/additionalInfo.d.ts +54 -2
- package/dist-es/additionalInfo.js +487 -306
- 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 +14 -8
- package/dist-es/descriptor.js +202 -186
- package/dist-es/descriptor.js.map +1 -1
- package/dist-es/helpers.d.ts +1 -1
- package/dist-es/helpers.js +4 -2
- package/dist-es/helpers.js.map +1 -1
- package/dist-es/imageResources.d.ts +15 -3
- package/dist-es/imageResources.js +503 -142
- package/dist-es/imageResources.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 +148 -17
- package/dist-es/psd.js.map +1 -1
- package/dist-es/psdReader.d.ts +10 -0
- package/dist-es/psdReader.js +278 -166
- package/dist-es/psdReader.js.map +1 -1
- package/dist-es/psdWriter.d.ts +1 -0
- package/dist-es/psdWriter.js +77 -62
- package/dist-es/psdWriter.js.map +1 -1
- package/dist-es/text.js +17 -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/src/abr.ts +375 -235
- package/src/additionalInfo.ts +663 -420
- package/src/ase.ts +66 -61
- package/src/descriptor.ts +199 -195
- package/src/helpers.ts +4 -1
- package/src/imageResources.ts +632 -168
- package/src/jpeg.ts +8 -8
- package/src/psd.ts +156 -30
- package/src/psdReader.ts +273 -172
- package/src/psdWriter.ts +95 -58
- package/src/text.ts +17 -6
- package/src/utf8.ts +0 -4
package/dist/ase.d.ts
CHANGED
|
@@ -29,4 +29,9 @@ export interface AseGroup {
|
|
|
29
29
|
export interface Ase {
|
|
30
30
|
colors: (AseGroup | AseColor)[];
|
|
31
31
|
}
|
|
32
|
-
export
|
|
32
|
+
export interface ReadAseOptions {
|
|
33
|
+
logMissingFeatures?: boolean;
|
|
34
|
+
/** Throw on unsupported or invalid blocks instead of skipping them */
|
|
35
|
+
throwForMissingFeatures?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function readAse(buffer: ArrayBufferView, options?: ReadAseOptions): Ase;
|
package/dist/ase.js
CHANGED
|
@@ -2,83 +2,83 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readAse = readAse;
|
|
4
4
|
const psdReader_1 = require("./psdReader");
|
|
5
|
-
function readAse(buffer) {
|
|
5
|
+
function readAse(buffer, options = {}) {
|
|
6
6
|
const reader = (0, psdReader_1.createReader)(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
7
7
|
const signature = (0, psdReader_1.readSignature)(reader); // ASEF
|
|
8
8
|
if (signature !== 'ASEF')
|
|
9
9
|
throw new Error('Invalid signature');
|
|
10
10
|
const versionMajor = (0, psdReader_1.readUint16)(reader); // 1
|
|
11
|
-
|
|
12
|
-
if (versionMajor !== 1
|
|
11
|
+
(0, psdReader_1.readUint16)(reader); // minor version: 0
|
|
12
|
+
if (versionMajor !== 1)
|
|
13
13
|
throw new Error('Invalid version');
|
|
14
14
|
const blocksCount = (0, psdReader_1.readUint32)(reader);
|
|
15
|
-
const colorTypes = ['global', 'spot', 'normal'];
|
|
16
15
|
const ase = { colors: [] };
|
|
17
16
|
let group = ase;
|
|
18
|
-
for (let i = 0; i < blocksCount; i++) {
|
|
17
|
+
for (let i = 0; i < blocksCount && reader.offset + 6 <= reader.view.byteLength; i++) {
|
|
19
18
|
const type = (0, psdReader_1.readUint16)(reader);
|
|
20
19
|
const length = (0, psdReader_1.readUint32)(reader);
|
|
21
|
-
const end = reader.offset + length;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
case 'CMYK':
|
|
38
|
-
color = {
|
|
39
|
-
c: (0, psdReader_1.readFloat32)(reader),
|
|
40
|
-
m: (0, psdReader_1.readFloat32)(reader),
|
|
41
|
-
y: (0, psdReader_1.readFloat32)(reader),
|
|
42
|
-
k: (0, psdReader_1.readFloat32)(reader),
|
|
43
|
-
type: colorTypes[(0, psdReader_1.readUint16)(reader)],
|
|
44
|
-
};
|
|
45
|
-
break;
|
|
46
|
-
case 'Gray':
|
|
47
|
-
color = {
|
|
48
|
-
k: (0, psdReader_1.readFloat32)(reader),
|
|
49
|
-
type: colorTypes[(0, psdReader_1.readUint16)(reader)],
|
|
50
|
-
};
|
|
51
|
-
break;
|
|
52
|
-
case 'LAB ':
|
|
53
|
-
color = {
|
|
54
|
-
l: (0, psdReader_1.readFloat32)(reader),
|
|
55
|
-
a: (0, psdReader_1.readFloat32)(reader),
|
|
56
|
-
b: (0, psdReader_1.readFloat32)(reader),
|
|
57
|
-
type: colorTypes[(0, psdReader_1.readUint16)(reader)],
|
|
58
|
-
};
|
|
59
|
-
break;
|
|
60
|
-
default:
|
|
61
|
-
throw new Error('Invalid color mode');
|
|
20
|
+
const end = Math.min(reader.offset + length, reader.view.byteLength);
|
|
21
|
+
// block reader, so invalid lengths can't make us read data of following blocks
|
|
22
|
+
const block = (0, psdReader_1.createReader)(reader.view.buffer, reader.view.byteOffset + reader.offset, end - reader.offset);
|
|
23
|
+
try {
|
|
24
|
+
switch (type) {
|
|
25
|
+
case 0x0001: { // color
|
|
26
|
+
const color = readAseColor(block);
|
|
27
|
+
if (color) {
|
|
28
|
+
group.colors.push(color);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (options.throwForMissingFeatures)
|
|
32
|
+
throw new Error('Unsupported color mode');
|
|
33
|
+
options.logMissingFeatures && reader.log('Skipped color with unsupported color mode');
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
62
36
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
37
|
+
case 0xC001: { // group start
|
|
38
|
+
const nameLength = (0, psdReader_1.readUint16)(block);
|
|
39
|
+
const name = (0, psdReader_1.readUnicodeStringWithLength)(block, nameLength);
|
|
40
|
+
ase.colors.push(group = { name, colors: [] });
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 0xC002: // group end
|
|
44
|
+
group = ase;
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
if (options.throwForMissingFeatures)
|
|
48
|
+
throw new Error(`Invalid block type: ${type}`);
|
|
49
|
+
options.logMissingFeatures && reader.log(`Skipped unknown block type: ${type}`);
|
|
73
50
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
if (options.throwForMissingFeatures)
|
|
54
|
+
throw e;
|
|
55
|
+
options.logMissingFeatures && reader.log(`Skipped invalid block: ${e.message}`);
|
|
79
56
|
}
|
|
80
57
|
reader.offset = end;
|
|
81
58
|
}
|
|
82
59
|
return ase;
|
|
83
60
|
}
|
|
61
|
+
function readAseColor(reader) {
|
|
62
|
+
const nameLength = (0, psdReader_1.readUint16)(reader);
|
|
63
|
+
const name = (0, psdReader_1.readUnicodeStringWithLength)(reader, nameLength);
|
|
64
|
+
const colorMode = (0, psdReader_1.readSignature)(reader);
|
|
65
|
+
// NaN and infinite values are replaced with 0
|
|
66
|
+
const value = () => {
|
|
67
|
+
const v = (0, psdReader_1.readFloat32)(reader);
|
|
68
|
+
return isFinite(v) ? v : 0;
|
|
69
|
+
};
|
|
70
|
+
// color type is sometimes missing, unknown types are treated as process (normal) colors
|
|
71
|
+
const colorType = () => {
|
|
72
|
+
const index = reader.offset + 2 <= reader.view.byteLength ? (0, psdReader_1.readUint16)(reader) : 2;
|
|
73
|
+
return colorTypes[index] || 'normal';
|
|
74
|
+
};
|
|
75
|
+
switch (colorMode) {
|
|
76
|
+
case 'RGB ': return { name, color: { r: value(), g: value(), b: value(), type: colorType() } };
|
|
77
|
+
case 'CMYK': return { name, color: { c: value(), m: value(), y: value(), k: value(), type: colorType() } };
|
|
78
|
+
case 'Gray': return { name, color: { k: value(), type: colorType() } };
|
|
79
|
+
case 'LAB ': return { name, color: { l: value(), a: value(), b: value(), type: colorType() } };
|
|
80
|
+
default: return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const colorTypes = ['global', 'spot', 'normal'];
|
|
84
84
|
//# sourceMappingURL=ase.js.map
|
package/dist/ase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ase.js","sourceRoot":"../src/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