mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
committed by
Lovell Fuller
parent
673d8278b5
commit
b69627891d
BIN
test/fixtures/expected/alpha-layer-1-fill-trim-resize.png
vendored
Normal file
BIN
test/fixtures/expected/alpha-layer-1-fill-trim-resize.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
BIN
test/fixtures/expected/trim-16bit-rgba.png
vendored
Normal file
BIN
test/fixtures/expected/trim-16bit-rgba.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
39
test/unit/trim.js
Normal file
39
test/unit/trim.js
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var sharp = require('../../index');
|
||||
var fixtures = require('../fixtures');
|
||||
|
||||
describe('Trim borders', function() {
|
||||
|
||||
it('Threshold default', function(done) {
|
||||
var expected = fixtures.expected('alpha-layer-1-fill-trim-resize.png');
|
||||
sharp(fixtures.inputPngOverlayLayer1)
|
||||
.resize(450, 322)
|
||||
.trim()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(450, info.width);
|
||||
assert.strictEqual(322, info.height);
|
||||
fixtures.assertSimilar(expected, data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('16-bit PNG with alpha channel', function(done) {
|
||||
sharp(fixtures.inputPngWithTransparency16bit)
|
||||
.resize(32, 32)
|
||||
.trim()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('png', info.format);
|
||||
assert.strictEqual(32, info.width);
|
||||
assert.strictEqual(32, info.height);
|
||||
assert.strictEqual(4, info.channels);
|
||||
fixtures.assertSimilar(fixtures.expected('trim-16bit-rgba.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user