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