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

unflatten images to make them transparent still keep white pixels around the edges of the image #3989

Closed
Nivg opened this issue Feb 12, 2024 · 4 comments
Labels

Comments

@Nivg
Copy link

Nivg commented Feb 12, 2024

I am using the unflatten command to make a version of a given image transparent.

Example for a given image:
300

Here is the result:
300_transparent

As you can see, I still have a residue of white pixels around the resulted image.

I'm not sure why, maybe I'm missing something regarding the understanding of how unflatten works?

Sample code (nothing special here):
await sharp(path.join(productPath, fileName + ".png")).unflatten().toFile(path.join(productPath, fileName + "_transparent.png"));

@Nivg Nivg added the question label Feb 12, 2024
@lovell
Copy link
Owner

lovell commented Feb 14, 2024

Did you see https://sharp.pixelplumbing.com/api-operation#unflatten ?

It looks like the "background" of this image consists of white and light grey pixels, with unflatten operating only on the white pixels as documented.

@Nivg
Copy link
Author

Nivg commented Feb 15, 2024

Did you see https://sharp.pixelplumbing.com/api-operation#unflatten ?

It looks like the "background" of this image consists of white and light grey pixels, with unflatten operating only on the white pixels as documented.

Yes, I have read the docs. Didn't notice the very light grey pixels, thank you for this insight.

I'll try to use several steps, first to transform the light grey pixels to white and then use the unflatten command.

Thanks!

@lovell
Copy link
Owner

lovell commented May 25, 2024

@Nivg Were you able to make progress with this?

@Nivg
Copy link
Author

Nivg commented May 26, 2024

@Nivg Were you able to make progress with this?

Unfortunately not yet; I am closing this, as the function is doing what it's suppose to do.
Thanks!

@Nivg Nivg closed this as completed May 26, 2024
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