mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Tests: remove use of SVG fixture from median tests
This commit is contained in:
parent
069d1786f5
commit
159b986cdd
@ -6,43 +6,44 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const sharp = require('../../');
|
const sharp = require('../../');
|
||||||
const fixtures = require('../fixtures');
|
|
||||||
|
|
||||||
describe('Median filter', () => {
|
const row = [0, 3, 15, 63, 127, 255];
|
||||||
it('1x1 window', async () => {
|
const input = Buffer.from(Array.from(row, () => row).flat());
|
||||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
const raw = {
|
||||||
.median(1)
|
width: 6,
|
||||||
|
height: 6,
|
||||||
|
channels: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('Median filter', function () {
|
||||||
|
it('default window (3x3)', async () => {
|
||||||
|
const data = await sharp(input, { raw })
|
||||||
|
.median()
|
||||||
|
.toColourspace('b-w')
|
||||||
.raw()
|
.raw()
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
assert.deepStrictEqual({ r: 0, g: 0, b: 0 }, { r, g, b });
|
assert.deepStrictEqual(data.subarray(0, 6), Buffer.from(row));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('3x3 window', async () => {
|
it('3x3 window', async () => {
|
||||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
const data = await sharp(input, { raw })
|
||||||
.median(3)
|
.median(3)
|
||||||
|
.toColourspace('b-w')
|
||||||
.raw()
|
.raw()
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
assert.deepStrictEqual({ r: 255, g: 0, b: 127 }, { r, g, b });
|
assert.deepStrictEqual(data.subarray(0, 6), Buffer.from(row));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('7x7 window', async () => {
|
it('5x5 window', async () => {
|
||||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
const data = await sharp(input, { raw })
|
||||||
.median(7)
|
.median(5)
|
||||||
|
.toColourspace('b-w')
|
||||||
.raw()
|
.raw()
|
||||||
.toBuffer();
|
.toBuffer();
|
||||||
|
|
||||||
assert.deepStrictEqual({ r: 255, g: 19, b: 146 }, { r, g, b });
|
assert.deepStrictEqual(data.subarray(0, 6), Buffer.from([0, 3, 15, 15, 63, 127]));
|
||||||
});
|
|
||||||
|
|
||||||
it('default window (3x3)', async () => {
|
|
||||||
const [r, g, b] = await sharp(fixtures.inputSvgSmallViewBox)
|
|
||||||
.median()
|
|
||||||
.raw()
|
|
||||||
.toBuffer();
|
|
||||||
|
|
||||||
assert.deepStrictEqual({ r: 255, g: 0, b: 127 }, { r, g, b });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('invalid radius', () => {
|
it('invalid radius', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user