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.

index.d.ts 695B

1234567891011121314151617181920212223242526272829303132
  1. /// <reference types="node"/>
  2. /**
  3. Check if a Buffer/Uint8Array is a [PNG](https://en.wikipedia.org/wiki/Portable_Network_Graphics) image.
  4. @param buffer - The buffer to check. It only needs the first 8 bytes.
  5. @returns Whether `buffer` contains a PNG image.
  6. @example
  7. ```
  8. // Node.js:
  9. import readChunk = require('read-chunk');
  10. import isPng = require('is-png');
  11. const buffer = readChunk.sync('unicorn.png', 0, 8);
  12. isPng(buffer);
  13. //=> true
  14. // Browser:
  15. (async () => {
  16. const response = await fetch('unicorn.png');
  17. const buffer = await response.arrayBuffer();
  18. isPng(new Uint8Array(buffer));
  19. //=> true
  20. })();
  21. ```
  22. */
  23. declare function isPng(buffer: Uint8Array | Buffer): boolean;
  24. export = isPng;