UNPKG

image-size

Version:
19 lines (15 loc) 567 B
'use strict'; // lib/types/utils.ts var decoder = new TextDecoder(); var toUTF8String = (input, start = 0, end = input.length) => decoder.decode(input.slice(start, end)); var getView = (input, offset) => new DataView(input.buffer, input.byteOffset + offset); var readUInt32BE = (input, offset = 0) => getView(input, offset).getUint32(0, false); // lib/types/psd.ts var PSD = { validate: (input) => toUTF8String(input, 0, 4) === "8BPS", calculate: (input) => ({ height: readUInt32BE(input, 14), width: readUInt32BE(input, 18) }) }; exports.PSD = PSD;