mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2024-12-26 19:58:25 +00:00
33 lines
4.9 KiB
JavaScript
33 lines
4.9 KiB
JavaScript
import { writePsd as writePsdInternal, getWriterBuffer, createWriter, getWriterBufferNoCopy } from './psdWriter';
|
|
import { readPsd as readPsdInternal, createReader } from './psdReader';
|
|
export * from './abr';
|
|
export * from './csh';
|
|
export { initializeCanvas } from './helpers';
|
|
export * from './psd';
|
|
import { fromByteArray } from 'base64-js';
|
|
export var byteArrayToBase64 = fromByteArray;
|
|
export function readPsd(buffer, options) {
|
|
var reader = 'buffer' in buffer ?
|
|
createReader(buffer.buffer, buffer.byteOffset, buffer.byteLength) :
|
|
createReader(buffer);
|
|
return readPsdInternal(reader, options);
|
|
}
|
|
export function writePsd(psd, options) {
|
|
var writer = createWriter();
|
|
writePsdInternal(writer, psd, options);
|
|
return getWriterBuffer(writer);
|
|
}
|
|
export function writePsdUint8Array(psd, options) {
|
|
var writer = createWriter();
|
|
writePsdInternal(writer, psd, options);
|
|
return getWriterBufferNoCopy(writer);
|
|
}
|
|
export function writePsdBuffer(psd, options) {
|
|
if (typeof Buffer === 'undefined') {
|
|
throw new Error('Buffer not supported on this platform');
|
|
}
|
|
return Buffer.from(writePsdUint8Array(psd, options));
|
|
}
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBYSxRQUFRLElBQUksZ0JBQWdCLEVBQUUsZUFBZSxFQUFFLFlBQVksRUFBRSxxQkFBcUIsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUM1SCxPQUFPLEVBQWEsT0FBTyxJQUFJLGVBQWUsRUFBRSxZQUFZLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDbEYsY0FBYyxPQUFPLENBQUM7QUFDdEIsY0FBYyxPQUFPLENBQUM7QUFDdEI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