USAGE: overlayWith('overlayimage.png', { cutout: true } )
BIN
test/fixtures/expected/overlay-cutout-gravity-center.jpg
vendored
Normal file
|
After Width: | Height: | Size: 795 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-centre.jpg
vendored
Normal file
|
After Width: | Height: | Size: 795 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-east.jpg
vendored
Normal file
|
After Width: | Height: | Size: 692 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-north.jpg
vendored
Normal file
|
After Width: | Height: | Size: 745 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-northeast.jpg
vendored
Normal file
|
After Width: | Height: | Size: 633 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-northwest.jpg
vendored
Normal file
|
After Width: | Height: | Size: 725 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-south.jpg
vendored
Normal file
|
After Width: | Height: | Size: 823 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-southeast.jpg
vendored
Normal file
|
After Width: | Height: | Size: 745 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-southwest.jpg
vendored
Normal file
|
After Width: | Height: | Size: 743 B |
BIN
test/fixtures/expected/overlay-cutout-gravity-west.jpg
vendored
Normal file
|
After Width: | Height: | Size: 745 B |
BIN
test/fixtures/expected/overlay-cutout-rotated90-gravity-northwest.jpg
vendored
Normal file
|
After Width: | Height: | Size: 699 B |
BIN
test/fixtures/expected/overlay-cutout-rotated90.jpg
vendored
Normal file
|
After Width: | Height: | Size: 842 B |
@@ -264,7 +264,6 @@ describe('Overlays', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('With tile enabled and image rotated 90 degrees', function(done) {
|
||||
var expected = fixtures.expected('overlay-tile-rotated90.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
@@ -283,7 +282,6 @@ describe('Overlays', function() {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it('With tile enabled and image rotated 90 degrees and gravity northwest', function(done) {
|
||||
var expected = fixtures.expected('overlay-tile-rotated90-gravity-northwest.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
@@ -303,4 +301,63 @@ describe('Overlays', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Overlay with cutout enabled and gravity', function() {
|
||||
Object.keys(sharp.gravity).forEach(function(gravity) {
|
||||
it(gravity, function(done) {
|
||||
var expected = fixtures.expected('overlay-cutout-gravity-' + gravity + '.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
.resize(80)
|
||||
.overlayWith(fixtures.inputPngWithTransparency16bit, {
|
||||
cutout: true,
|
||||
gravity: gravity
|
||||
})
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(80, info.width);
|
||||
assert.strictEqual(65, info.height);
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(expected, data, done);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('With cutout enabled and image rotated 90 degrees', function(done) {
|
||||
var expected = fixtures.expected('overlay-cutout-rotated90.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
.rotate(90)
|
||||
.resize(80)
|
||||
.overlayWith(fixtures.inputPngWithTransparency16bit, {
|
||||
cutout: true
|
||||
})
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(80, info.width);
|
||||
assert.strictEqual(98, info.height);
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(expected, data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('With cutout enabled and image rotated 90 degrees and gravity northwest', function(done) {
|
||||
var expected = fixtures.expected('overlay-cutout-rotated90-gravity-northwest.jpg');
|
||||
sharp(fixtures.inputJpg)
|
||||
.rotate(90)
|
||||
.resize(80)
|
||||
.overlayWith(fixtures.inputPngWithTransparency16bit, {
|
||||
cutout: true,
|
||||
gravity: 'northwest'
|
||||
})
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(80, info.width);
|
||||
assert.strictEqual(98, info.height);
|
||||
assert.strictEqual(3, info.channels);
|
||||
fixtures.assertSimilar(expected, data, done);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||