Skip to content

Commit

Permalink
Prevent double unpremultiply with some composite blends
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed Mar 4, 2022
1 parent dd3b782 commit 23033e2
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Requires libvips v8.12.2

### v0.30.3 - TBD

* Prevent double unpremultiply with some composite blend modes (regression in 0.30.2).
[#3118](https://github.com/lovell/sharp/issues/3118)

### v0.30.2 - 2nd March 2022

* Improve performance and accuracy when compositing multiple images.
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class PipelineWorker : public Napi::AsyncWorker {
}

bool const shouldPremultiplyAlpha = sharp::HasAlpha(image) &&
(shouldResize || shouldBlur || shouldConv || shouldSharpen || shouldComposite);
(shouldResize || shouldBlur || shouldConv || shouldSharpen);

// Premultiply image alpha channel before all transformations to avoid
// dark fringing around bright pixels
Expand Down
Binary file modified test/fixtures/expected/composite-multiple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/expected/composite.blend.dest-over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/expected/composite.blend.over.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/expected/composite.blend.saturate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/expected/composite.blend.xor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/unit/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ describe('Extend', function () {
})
.raw()
.toBuffer();
assert.deepStrictEqual(Array.from(data), [191, 25, 65, 204, 238, 31, 82, 204]);
assert.deepStrictEqual(Array.from(data), [191, 25, 66, 204, 191, 25, 66, 204]);
});
});

0 comments on commit 23033e2

Please sign in to comment.