UNPKG

arx-level-generator

Version:
24 lines 706 B
import sharp from 'sharp'; import { sharpFromBmp } from 'sharp-bmp'; const cache = {}; const load = async (filename) => { const image = filename.endsWith('bmp') ? sharpFromBmp(filename) : sharp(filename); const metadata = await image.metadata(); cache[filename] = { image, metadata, }; }; export const getMetadata = async (filename) => { if (typeof cache[filename] === 'undefined') { await load(filename); } return cache[filename].metadata; }; export const getSharpInstance = async (filename) => { if (typeof cache[filename] === 'undefined') { await load(filename); } return cache[filename].image; }; //# sourceMappingURL=image.js.map