|
1 |
| -import { encodePng } from '../../save'; |
| 1 | +import path from 'node:path'; |
2 | 2 |
|
3 |
| -test.skip('compare result of resize with opencv (nearest)', () => { |
| 3 | +import { encodePng, write } from '../../save'; |
| 4 | + |
| 5 | +test('compare result of resize with opencv (nearest)', async () => { |
4 | 6 | const img = testUtils.load('opencv/test.png');
|
| 7 | + const expectedImg = testUtils.load('opencv/testResizeNearest.png'); |
5 | 8 |
|
6 | 9 | const resized = img.resize({
|
7 | 10 | xFactor: 10,
|
8 | 11 | yFactor: 10,
|
9 | 12 | interpolationType: 'nearest',
|
10 | 13 | });
|
11 | 14 |
|
| 15 | + const substraction = expectedImg.clone().subtract(resized); |
| 16 | + await write( |
| 17 | + path.join(__dirname, 'resize_nearest_substraction.png'), |
| 18 | + substraction, |
| 19 | + ); |
| 20 | + await write(path.join(__dirname, 'resize_nearest.png'), resized); |
| 21 | + |
12 | 22 | expect(resized).toMatchImage('opencv/testResizeNearest.png');
|
13 | 23 | });
|
14 | 24 |
|
15 |
| -test.skip('compare result of resize with opencv (bilinear)', () => { |
| 25 | +test.skip('compare result of resize with opencv (bilinear)', async () => { |
16 | 26 | const img = testUtils.load('opencv/test.png');
|
| 27 | + const expectedImg = testUtils.load('opencv/testResizeBilinear.png'); |
17 | 28 |
|
18 | 29 | const resized = img.resize({
|
19 | 30 | xFactor: 10,
|
20 | 31 | yFactor: 10,
|
21 | 32 | });
|
22 | 33 |
|
| 34 | + const substraction = expectedImg.clone().subtract(resized); |
| 35 | + await write( |
| 36 | + path.join(__dirname, 'resize_bilinear_substraction.png'), |
| 37 | + substraction, |
| 38 | + ); |
| 39 | + await write(path.join(__dirname, 'resize_bilinear.png'), resized); |
| 40 | + |
23 | 41 | expect(resized).toMatchImage('opencv/testResizeBilinear.png');
|
24 | 42 | });
|
25 | 43 |
|
|
0 commit comments