Skip to content

Commit

Permalink
Fix y-axis calc when overlaying at fixed point #566
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Sep 16, 2016
1 parent 86039a3 commit 28ce33f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 21 additions & 1 deletion test/unit/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

Expand Down

0 comments on commit 28ce33f

Please sign in to comment.