Utilities for map projections.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
428 B

  1. import { PNG } from 'pngjs';
  2. import { readFile } from 'fs/promises';
  3. export const load = async (pngInput: string | Buffer | PNG) => {
  4. if (typeof pngInput === 'string') {
  5. const pngFile = await readFile(pngInput);
  6. return PNG.sync.read(pngFile);
  7. }
  8. if (typeof pngInput === 'object') {
  9. return pngInput instanceof PNG ? pngInput : PNG.sync.read(pngInput);
  10. }
  11. throw new TypeError('Invalid input argument.');
  12. };