tiff.test.js 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Jimp, getTestDir } from '@jimp/test-utils';
  2. import configure from '@jimp/custom';
  3. import tiff from '../src';
  4. const jimp = configure({ types: [tiff] }, Jimp);
  5. describe('TIFF', () => {
  6. const imagesDir = getTestDir(__dirname) + '/images';
  7. it('load TIFF', async () => {
  8. const image = await jimp.read(imagesDir + '/rgb.tiff');
  9. image.getPixelColor(10, 10).should.be.equal(0xa4988bff);
  10. image.getPixelColor(220, 190).should.be.equal(0xe0d7ddff);
  11. image.getPixelColor(350, 130).should.be.equal(0x565433ff);
  12. });
  13. const simpleJGD = {
  14. width: 3,
  15. height: 3,
  16. data: [
  17. 0xff0000ff,
  18. 0xff0080ff,
  19. 0xff00ffff,
  20. 0xff0080ff,
  21. 0xff00ffff,
  22. 0x8000ffff,
  23. 0xff00ffff,
  24. 0x8000ffff,
  25. 0x0000ffff
  26. ]
  27. };
  28. it('export TIFF', async () => {
  29. const image = await jimp.read(simpleJGD);
  30. const buffer = await image.getBufferAsync('image/tiff');
  31. buffer.toString().should.match(/^MM\u0000*\u0000/);
  32. });
  33. });