Fix y-axis calc when overlaying at fixed point #566

This commit is contained in:
Lovell Fuller 2016-09-16 11:20:08 +01:00
parent 86039a3f2b
commit 28ce33feb3
4 changed files with 26 additions and 2 deletions

View File

@ -10,6 +10,10 @@ Requires libvips v8.3.3
[#561](https://github.com/lovell/sharp/issues/561)
[@abagshaw](https://github.com/abagshaw)
* Correct calculation of y-axis placement when overlaying image at a fixed point.
[#566](https://github.com/lovell/sharp/issues/566)
[@Nateowami](https://github.com/Nateowami)
#### v0.16.0 - 18<sup>th</sup> August 2016
* Add pre-compiled libvips for OS X, ARMv7 and ARMv8.

View File

@ -391,7 +391,7 @@ namespace sharp {
if(y >= 0 && y < (inHeight - outHeight)) {
top = y;
} else if(x >= (inHeight - outHeight)) {
} else if(y >= (inHeight - outHeight)) {
top = inHeight - outHeight;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -437,7 +437,27 @@ describe('Overlays', function() {
assert.strictEqual(3, info.channels);
fixtures.assertSimilar(expected, data, done);
});
});
it('Overlay 100x100 with 50x50 so bottom edges meet', function(done) {
sharp(fixtures.inputJpg)
.resize(50, 50)
.toBuffer(function(err, overlay) {
if (err) throw err;
sharp(fixtures.inputJpgWithLandscapeExif1)
.resize(100, 100)
.overlayWith(overlay, {
top: 50,
left: 40
})
.toBuffer(function(err, data, info) {
if (err) throw err;
assert.strictEqual('jpeg', info.format);
assert.strictEqual(100, info.width);
assert.strictEqual(100, info.height);
fixtures.assertSimilar(fixtures.expected('overlay-bottom-edges-meet.jpg'), data, done);
});
});
});
});