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 parameters like clear, source not working as expected. #3076

Closed
g-abhishek opened this issue Feb 7, 2022 · 6 comments
Closed
Labels

Comments

@g-abhishek
Copy link

What are you trying to achieve?
I am trying to have blend transformation, which is one of the property of composite api, for my image transformation and stucked in a output which is different than given in the cairographics.org website

Have you searched for similar questions?
Yes, but didn't got any solution

Are you able to provide a minimal, standalone code sample that demonstrates this question?

try {
    await sharp("largeImage.jpeg")
      .composite([
        {
          input: "small.jpeg",
          gravity: “center”,
          blend: “clear”, // source, dest-out, etc
        },
      ])
      .toFile(“output.jpeg”);
  } catch (error) {
    console.log(error);
  }
}

Are you able to provide a sample image that helps explain the question?
Input images :-
largeImage
small

Output images :-
for blend type clear,
outputClear

for blend type source,
outputSource

@g-abhishek g-abhishek changed the title Composite blend paramters like clear, source not working as expected. Composite blend parameters like clear, source not working as expected. Feb 7, 2022
@lovell
Copy link
Owner

lovell commented Feb 7, 2022

Hi, most compositing blends/operators require an alpha channel on at least one image. The two input images provided here are both JPEGs, which does not support an alpha channel.

@g-abhishek
Copy link
Author

I tried with PNGs images, with one image(big one) has alpha channel, but still getting the same output.

Input Images :-
large_png
200

Output Images :-
for blend type clear,
clear

for blend type source,
source

@lovell
Copy link
Owner

lovell commented Feb 9, 2022

Those outputs appear to be correct for clear and source, which aren't particularly useful blend modes. Perhaps you intended to use over (the default)?

@g-abhishek
Copy link
Author

If you see the https://www.cairographics.org/operators/ documentation, output given here is different than the generated one for clear and souce

cairographics

@g-abhishek
Copy link
Author

g-abhishek commented Feb 14, 2022

@lovell Can you please refer the https://www.cairographics.org/operators/ docs once and check is this correct or not?

@lovell
Copy link
Owner

lovell commented Feb 16, 2022

The way the composite operation works has been improved via commit c620025

I noticed that when compositing 3 or more images, the accuracy of the blend mode could suffer, and the clear and source modes particularly so as they would consider the combination of the previous 2 layers rather than 1st layer. Thanks for bringing this to my attention - let's track this at #2286

@lovell lovell closed this as completed Feb 16, 2022
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