normalize.test.js 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { Jimp, mkJGD } from '@jimp/test-utils';
  2. import configure from '@jimp/custom';
  3. import normalize from '../src';
  4. const jimp = configure({ plugins: [normalize] }, Jimp);
  5. describe('Normalize', () => {
  6. it('change grayscale image', async () => {
  7. const image = await jimp.read(mkJGD('36▦', '6▦9', '▦9C'));
  8. image
  9. .normalize()
  10. .getJGDSync()
  11. .should.be.sameJGD(mkJGD('■5▦', '5▦A', '▦A□'));
  12. });
  13. it('change red/blue image', async () => {
  14. const image = await jimp.read({
  15. width: 3,
  16. height: 2,
  17. data: [
  18. 0x000000ff,
  19. 0x400022ff,
  20. 0x40002200,
  21. 0x400000ff,
  22. 0x000022ff,
  23. 0x800055ff
  24. ]
  25. });
  26. image
  27. .normalize()
  28. .getJGDSync()
  29. .should.be.sameJGD({
  30. width: 3,
  31. height: 2,
  32. data: [
  33. 0x000000ff,
  34. 0x7f0066ff,
  35. 0x7f006600,
  36. 0x7f0000ff,
  37. 0x000066ff,
  38. 0xff00ffff
  39. ]
  40. });
  41. });
  42. });