gif.js 350 B

12345678910111213141516171819
  1. 'use strict';
  2. var gifRegexp = /^GIF8[79]a/;
  3. function isGIF (buffer) {
  4. var signature = buffer.toString('ascii', 0, 6);
  5. return (gifRegexp.test(signature));
  6. }
  7. function calculate(buffer) {
  8. return {
  9. 'width': buffer.readUInt16LE(6),
  10. 'height': buffer.readUInt16LE(8)
  11. };
  12. }
  13. module.exports = {
  14. 'detect': isGIF,
  15. 'calculate': calculate
  16. };