mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose erode and dilate operations #4243
This commit is contained in:
committed by
Lovell Fuller
parent
03e1b19764
commit
031c808aa5
38
test/unit/dilate.js
Normal file
38
test/unit/dilate.js
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
const sharp = require('../../');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('Dilate', function () {
|
||||
it('dilate 1 png', function (done) {
|
||||
sharp(fixtures.inputPngDotAndLines)
|
||||
.dilate(1)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(100, info.width);
|
||||
assert.strictEqual(100, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('dilate-1.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('dilate 1 png - default width', function (done) {
|
||||
sharp(fixtures.inputPngDotAndLines)
|
||||
.dilate()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(100, info.width);
|
||||
assert.strictEqual(100, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('dilate-1.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid dilation width', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg).dilate(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
38
test/unit/erode.js
Normal file
38
test/unit/erode.js
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
const sharp = require('../../');
|
||||
const fixtures = require('../fixtures');
|
||||
|
||||
describe('Erode', function () {
|
||||
it('erode 1 png', function (done) {
|
||||
sharp(fixtures.inputPngDotAndLines)
|
||||
.erode(1)
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(100, info.width);
|
||||
assert.strictEqual(100, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('erode-1.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('erode 1 png - default width', function (done) {
|
||||
sharp(fixtures.inputPngDotAndLines)
|
||||
.erode()
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(100, info.width);
|
||||
assert.strictEqual(100, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('erode-1.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('invalid erosion width', function () {
|
||||
assert.throws(function () {
|
||||
sharp(fixtures.inputJpg).erode(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user