unflatten images to make them transparent still keep white pixels around the edges of the image
I am using the unflatten command to make a version of a given image transparent.
Example for a given image:
Here is the result:
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"));
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.
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
unflattenoperating 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!
@Nivg Were you able to make progress with this?
@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!