@yft-design/psd-lib 1.0.1
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/README.md +45 -0
- package/dist/abr.d.ts +143 -0
- package/dist/abr.js +300 -0
- package/dist/additionalInfo.d.ts +26 -0
- package/dist/additionalInfo.js +3891 -0
- package/dist/csh.d.ts +10 -0
- package/dist/csh.js +32 -0
- package/dist/descriptor.d.ts +566 -0
- package/dist/descriptor.js +1958 -0
- package/dist/effectsHelpers.d.ts +5 -0
- package/dist/effectsHelpers.js +280 -0
- package/dist/engineData.d.ts +2 -0
- package/dist/engineData.js +330 -0
- package/dist/engineData2.d.ts +2 -0
- package/dist/engineData2.js +405 -0
- package/dist/helpers.d.ts +89 -0
- package/dist/helpers.js +300 -0
- package/dist/imageResources.d.ts +17 -0
- package/dist/imageResources.js +1070 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +30 -0
- package/dist/initializeCanvas.d.ts +1 -0
- package/dist/initializeCanvas.js +21 -0
- package/dist/jpeg.d.ts +1 -0
- package/dist/jpeg.js +1017 -0
- package/dist/psd.d.ts +1822 -0
- package/dist/psd.js +7 -0
- package/dist/psdReader.d.ts +46 -0
- package/dist/psdReader.js +1188 -0
- package/dist/psdWriter.d.ts +33 -0
- package/dist/psdWriter.js +733 -0
- package/dist/text.d.ts +179 -0
- package/dist/text.js +556 -0
- package/dist/utf8.d.ts +4 -0
- package/dist/utf8.js +150 -0
- package/package.json +46 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Psd, ReadOptions, WriteOptions } from './psd';
|
|
2
|
+
import { PsdWriter } from './psdWriter';
|
|
3
|
+
import { PsdReader } from './psdReader';
|
|
4
|
+
import { fromByteArray } from 'base64-js';
|
|
5
|
+
export * from './abr';
|
|
6
|
+
export * from './csh';
|
|
7
|
+
export { initializeCanvas } from './helpers';
|
|
8
|
+
export * from './psd';
|
|
9
|
+
export type { PsdReader, PsdWriter };
|
|
10
|
+
interface BufferLike {
|
|
11
|
+
buffer: ArrayBufferLike;
|
|
12
|
+
byteOffset: number;
|
|
13
|
+
byteLength: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const byteArrayToBase64: typeof fromByteArray;
|
|
16
|
+
export declare function readPsd(buffer: ArrayBuffer | BufferLike, options?: ReadOptions): Psd;
|
|
17
|
+
export declare function writePsd(psd: Psd, options?: WriteOptions): ArrayBuffer;
|
|
18
|
+
export declare function writePsdUint8Array(psd: Psd, options?: WriteOptions): Uint8Array;
|
|
19
|
+
export declare function writePsdBuffer(psd: Psd, options?: WriteOptions): Buffer;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { writePsd as writePsdInternal, getWriterBuffer, createWriter, getWriterBufferNoCopy } from './psdWriter';
|
|
2
|
+
import { readPsd as readPsdInternal, createReader } from './psdReader';
|
|
3
|
+
import { fromByteArray } from 'base64-js';
|
|
4
|
+
export * from './abr';
|
|
5
|
+
export * from './csh';
|
|
6
|
+
export { initializeCanvas } from './helpers';
|
|
7
|
+
export * from './psd';
|
|
8
|
+
export const byteArrayToBase64 = fromByteArray;
|
|
9
|
+
export function readPsd(buffer, options) {
|
|
10
|
+
const reader = 'buffer' in buffer ?
|
|
11
|
+
createReader(buffer.buffer, buffer.byteOffset, buffer.byteLength) :
|
|
12
|
+
createReader(buffer);
|
|
13
|
+
return readPsdInternal(reader, options);
|
|
14
|
+
}
|
|
15
|
+
export function writePsd(psd, options) {
|
|
16
|
+
const writer = createWriter();
|
|
17
|
+
writePsdInternal(writer, psd, options);
|
|
18
|
+
return getWriterBuffer(writer);
|
|
19
|
+
}
|
|
20
|
+
export function writePsdUint8Array(psd, options) {
|
|
21
|
+
const writer = createWriter();
|
|
22
|
+
writePsdInternal(writer, psd, options);
|
|
23
|
+
return getWriterBufferNoCopy(writer);
|
|
24
|
+
}
|
|
25
|
+
export function writePsdBuffer(psd, options) {
|
|
26
|
+
if (typeof Buffer === 'undefined') {
|
|
27
|
+
throw new Error('Buffer not supported on this platform');
|
|
28
|
+
}
|
|
29
|
+
return Buffer.from(writePsdUint8Array(psd, options));
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initialize(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createCanvas } from 'canvas';
|
|
2
|
+
import { initializeCanvas } from './index';
|
|
3
|
+
import { decodeJpeg } from './jpeg';
|
|
4
|
+
function createCanvasFromData(data) {
|
|
5
|
+
const canvas = createCanvas(100, 100);
|
|
6
|
+
try {
|
|
7
|
+
const context = canvas.getContext('2d');
|
|
8
|
+
const imageData = decodeJpeg(data, (w, h) => context.createImageData(w, h));
|
|
9
|
+
canvas.width = imageData.width;
|
|
10
|
+
canvas.height = imageData.height;
|
|
11
|
+
context.putImageData(imageData, 0, 0);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
console.error('JPEG decompression error', e.message);
|
|
15
|
+
}
|
|
16
|
+
return canvas;
|
|
17
|
+
}
|
|
18
|
+
initializeCanvas(createCanvas, createCanvasFromData);
|
|
19
|
+
export function initialize() {
|
|
20
|
+
initializeCanvas(createCanvas, createCanvasFromData);
|
|
21
|
+
}
|
package/dist/jpeg.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decodeJpeg(encoded: Uint8Array, createImageData: (width: number, height: number) => ImageData): ImageData;
|