Remove (un)premultiply ops when not resizing/compositing #413

This commit is contained in:
Lovell Fuller 2016-04-23 19:50:00 +01:00
parent 531a0402f7
commit c920180cb3
4 changed files with 11 additions and 5 deletions

View File

@ -4,6 +4,12 @@
Requires libvips v8.2.3 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 - 16<sup>th</sup> April 2016 #### v0.14.1 - 16<sup>th</sup> April 2016
* Allow removal of limitation on input pixel count via limitInputPixels. Use with care. * Allow removal of limitation on input pixel count via limitInputPixels. Use with care.

View File

@ -288,12 +288,12 @@ class PipelineWorker : public AsyncWorker {
// are already less than the required dimensions // are already less than the required dimensions
if (baton->withoutEnlargement) { if (baton->withoutEnlargement) {
if (inputWidth < baton->width || inputHeight < baton->height) { if (inputWidth < baton->width || inputHeight < baton->height) {
xfactor = 1; xfactor = 1.0;
yfactor = 1; yfactor = 1.0;
xshrink = 1; xshrink = 1;
yshrink = 1; yshrink = 1;
xresidual = 0; xresidual = 1.0;
yresidual = 0; yresidual = 1.0;
baton->width = inputWidth; baton->width = inputWidth;
baton->height = inputHeight; 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 shouldBlur = baton->blurSigma != 0.0;
bool shouldSharpen = baton->sharpenRadius != 0; bool shouldSharpen = baton->sharpenRadius != 0;
bool shouldThreshold = baton->threshold != 0; bool shouldThreshold = baton->threshold != 0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 755 B

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 23 KiB