Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composite blend mode "in" causing resulting color different from source color if the destination is not opaque (alpha is less than 1) #1706

Closed
MrNghia123 opened this issue May 19, 2019 · 1 comment
Labels

Comments

@MrNghia123
Copy link

What is the output of running npx envinfo --binaries --languages --system --utilities?
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
Memory: 420.60 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.1 - /usr/local/bin/node
Yarn: 1.3.2 - /usr/local/bin/yarn
npm: 5.6.0 - /usr/local/bin/npm
Utilities:
Git: 2.18.0 - /usr/local/bin/git
Languages:
Bash: 3.2.57 - /bin/bash
Java: 1.8.0_60 - /usr/bin/javac
Perl: 5.18.2 - /usr/bin/perl
PHP: 7.2.7 - /usr/local/bin/php
Python: 2.7.15 - /usr/local/bin/python
Ruby: 2.3.7 - /usr/bin/ruby
What are the steps to reproduce?

1/ create color rectangle with { r: 127, g: 255, b: 127, alpha: 1 } to use as the source
2/ create semi transparent rect with { r: 0, g: 0, b: 0, alpha: 0.8 } to use as the destination
apply the source to the destination by composite with blend mode "in"

What is the expected behaviour?

the outcome should have the color of the source and the alpha of the destination { r: 127, g: 255, b: 127, alpha: 0.8}, instead, the result is { r: 158, g: 255, b: 158, alpha: 0.8}.

Are you able to provide a standalone code sample, without other dependencies, that demonstrates this problem?

sharp({
create: {
width: 300,
height: 200,
channels: 4,
background: { r: 127, g: 255, b: 127, alpha: 1 }
}
})
.png()
.toBuffer()
.then(colorPanel=>{
sharp({
create: {
width: 300,
height: 200,
channels: 4,
background : { r: 0, g: 0, b: 0, alpha: 0.8 }
},
})
.composite([
{
input: colorPanel,
blend: 'in'
}
])
.toFile('img/test.png')
})

Are you able to provide a sample image that helps explain the problem?

All the images can be created with code

@lovell
Copy link
Owner

lovell commented May 19, 2019

Hi, this looks like the same problem as #1676, which relates to brighter-than-expected output pixel values when the alpha channel is semi-transparent.

@lovell lovell closed this as completed Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants