mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Changelog/doc/test updates for various new operations
Dependency version bumps
This commit is contained in:
@@ -6,46 +6,34 @@ var sharp = require('../../index');
|
||||
|
||||
describe('Bandbool per-channel boolean operations', function() {
|
||||
|
||||
it('\'and\' Operation', function(done) {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool('and')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
assert.strictEqual(1, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('bandbool_and_result.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('\'or\' Operation', function(done) {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool(sharp.bool.or)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
assert.strictEqual(1, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('bandbool_or_result.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('\'eor\' Operation', function(done) {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool('eor')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
assert.strictEqual(1, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('bandbool_eor_result.png'), data, done);
|
||||
});
|
||||
[
|
||||
sharp.bool.and,
|
||||
sharp.bool.or,
|
||||
sharp.bool.eor
|
||||
]
|
||||
.forEach(function(op) {
|
||||
it(op + ' operation', function(done) {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool(op)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(200, info.width);
|
||||
assert.strictEqual(200, info.height);
|
||||
assert.strictEqual(1, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('bandbool_' + op + '_result.png'), data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid operation', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputPngBooleanNoAlpha)
|
||||
.bandbool('fail');
|
||||
sharp().bandbool('fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('Missing operation', function() {
|
||||
assert.throws(function() {
|
||||
sharp().bandbool();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,97 +7,56 @@ var sharp = require('../../index');
|
||||
|
||||
describe('Boolean operation between two images', function() {
|
||||
|
||||
it('\'and\' Operation, file', function(done) {
|
||||
sharp(fixtures.inputJpg) //fixtures.inputJpg
|
||||
.resize(320,240)
|
||||
.boolean(fixtures.inputJpgBooleanTest, 'and')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_and_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
var inputJpgBooleanTestBuffer = fs.readFileSync(fixtures.inputJpgBooleanTest);
|
||||
|
||||
it('\'and\' Operation, buffer', function(done) {
|
||||
sharp(fixtures.inputJpg) //fixtures.inputJpg
|
||||
.resize(320,240)
|
||||
.boolean(fs.readFileSync(fixtures.inputJpgBooleanTest), sharp.bool.and)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_and_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
[
|
||||
sharp.bool.and,
|
||||
sharp.bool.or,
|
||||
sharp.bool.eor
|
||||
]
|
||||
.forEach(function(op) {
|
||||
|
||||
it('\'or\' Operation, file', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320,240)
|
||||
.boolean(fixtures.inputJpgBooleanTest, sharp.bool.or)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_or_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
it(op + ' operation, file', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.boolean(fixtures.inputJpgBooleanTest, op)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_' + op + '_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('\'or\' Operation, buffer', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320,240)
|
||||
.boolean(fs.readFileSync(fixtures.inputJpgBooleanTest), 'or')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_or_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
it(op + ' operation, buffer', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320, 240)
|
||||
.boolean(inputJpgBooleanTestBuffer, op)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_' + op + '_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('\'eor\' Operation, file', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320,240)
|
||||
.boolean(fixtures.inputJpgBooleanTest, 'eor')
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_eor_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('\'eor\' Operation, buffer', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320,240)
|
||||
.boolean(fs.readFileSync(fixtures.inputJpgBooleanTest), sharp.bool.eor)
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(240, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('boolean_eor_result.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid operation', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputJpg)
|
||||
.boolean(fs.readFileSync(fixtures.inputJpgBooleanTest), 'fail');
|
||||
sharp().boolean(fixtures.inputJpgBooleanTest, 'fail');
|
||||
});
|
||||
});
|
||||
|
||||
it('Invalid operation, non-string', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputJpg)
|
||||
.boolean(fs.readFileSync(fixtures.inputJpgBooleanTest), null);
|
||||
sharp().boolean(fixtures.inputJpgBooleanTest, null);
|
||||
});
|
||||
});
|
||||
|
||||
if('Invalid buffer input', function() {
|
||||
if('Invalid input', function() {
|
||||
assert.throws(function() {
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(320,240)
|
||||
.boolean([],'eor');
|
||||
sharp().boolean([], 'eor');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user