diff --git a/docs/changelog.md b/docs/changelog.md index 67704ccd..9da8829d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 - 30th May 2017 * Remove the previously-deprecated output format "option" functions: diff --git a/src/pipeline.cc b/src/pipeline.cc index 3739df42..d26dbf4a 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -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; diff --git a/test/unit/resize.js b/test/unit/resize.js index 58aafd47..4664be78 100644 --- a/test/unit/resize.js +++ b/test/unit/resize.js @@ -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(); + }); + }); });