diff --git a/docs/changelog.md b/docs/changelog.md index ca8dcc4d..13756a3b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,6 +4,12 @@ Requires libvips v8.2.3 +#### v0.14.2 - TBD + +* Remove unnecessary (un)premultiply operations when not resizing/compositing. + [#413](https://github.com/lovell/sharp/issues/413) + [@jardakotesovec](https://github.com/jardakotesovec) + #### v0.14.1 - 16th April 2016 * Allow removal of limitation on input pixel count via limitInputPixels. Use with care. diff --git a/src/pipeline.cc b/src/pipeline.cc index 35e23a49..2518c0f5 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -288,12 +288,12 @@ class PipelineWorker : public AsyncWorker { // are already less than the required dimensions if (baton->withoutEnlargement) { if (inputWidth < baton->width || inputHeight < baton->height) { - xfactor = 1; - yfactor = 1; + xfactor = 1.0; + yfactor = 1.0; xshrink = 1; yshrink = 1; - xresidual = 0; - yresidual = 0; + xresidual = 1.0; + yresidual = 1.0; baton->width = inputWidth; baton->height = inputHeight; } @@ -431,7 +431,7 @@ class PipelineWorker : public AsyncWorker { ); } - bool shouldAffineTransform = xresidual != 0.0 || yresidual != 0.0; + bool shouldAffineTransform = xresidual != 1.0 || yresidual != 1.0; bool shouldBlur = baton->blurSigma != 0.0; bool shouldSharpen = baton->sharpenRadius != 0; bool shouldThreshold = baton->threshold != 0; diff --git a/test/fixtures/expected/embed-16bit-rgba.png b/test/fixtures/expected/embed-16bit-rgba.png index 70e3f365..e50edc89 100644 Binary files a/test/fixtures/expected/embed-16bit-rgba.png and b/test/fixtures/expected/embed-16bit-rgba.png differ diff --git a/test/fixtures/expected/threshold-128-transparency.webp b/test/fixtures/expected/threshold-128-transparency.webp index c86a254f..cd1f2f5a 100644 Binary files a/test/fixtures/expected/threshold-128-transparency.webp and b/test/fixtures/expected/threshold-128-transparency.webp differ