threshold.test.js 800 B

123456789101112131415161718192021222324252627282930
  1. import { Jimp, getTestDir } from '@jimp/test-utils';
  2. import configure from '@jimp/custom';
  3. import jpeg from '@jimp/jpeg';
  4. import color from '@jimp/plugin-color';
  5. import resize from '@jimp/plugin-resize';
  6. import threshold from '../src';
  7. const jimp = configure(
  8. { types: [jpeg], plugins: [threshold, color, resize] },
  9. Jimp
  10. );
  11. describe('Threshold', function() {
  12. this.timeout(15000);
  13. it('defines default threshold for lighter backgrounds', async () => {
  14. const expectedImage = await jimp.read(
  15. getTestDir(__dirname) + '/images/hands_mx200_rp255.jpg'
  16. );
  17. const testImage = await jimp.read(
  18. getTestDir(__dirname) + '/images/hands.jpg'
  19. );
  20. testImage
  21. .threshold({ max: 200, replace: 255 })
  22. .hash()
  23. .should.be.equal(expectedImage.hash());
  24. });
  25. });