Correct shrink calc, regression introduced in e398b47 #831

This commit is contained in:
Lovell Fuller 2017-05-30 17:16:41 +01:00
parent c879df3b31
commit 9e39a7fa95
3 changed files with 18 additions and 1 deletions

View File

@ -4,6 +4,12 @@
Requires libvips v8.5.5.
#### v0.18.1 - TBD
* Remove regression from #781 that could cause incorrect shrink calculation.
[#831](https://github.com/lovell/sharp/issues/831)
[@suprMax](https://github.com/suprMax)
#### v0.18.0 - 30<sup>th</sup> May 2017
* Remove the previously-deprecated output format "option" functions:

View File

@ -288,7 +288,7 @@ class PipelineWorker : public Nan::AsyncWorker {
}
}
// Help ensure a final kernel-based reduction to prevent shrink aliasing
if ((xshrink > 1 || yshrink > 1) && (xresidual == 1.0 || yresidual == 1.0)) {
if (xshrink > 1 && yshrink > 1 && (xresidual == 1.0 || yresidual == 1.0)) {
xshrink = xshrink / 2;
yshrink = yshrink / 2;
xresidual = xresidual / 2.0;

View File

@ -412,4 +412,15 @@ describe('Resize dimensions', function () {
sharp().resize(32, 24, { centreSampling: 1 });
});
});
it('Dimensions that result in differing shrinks on each axis', function () {
return sharp(fixtures.inputJpg)
.resize(645, 399)
.toBuffer()
.then(function (data) {
return sharp(data)
.resize(150, 100)
.toBuffer();
});
});
});