vtracer icon indicating copy to clipboard operation
vtracer copied to clipboard

Alpha channel handling in PNG images

Open dbalabka opened this issue 3 years ago • 5 comments

I've been faced with the problem that the alpha channel in PNG images isn't supported properly. The transparent part of the image will be prepared with black filling: image

The expected result is to keep transparency in SVG, by not having shapes at this place at all.

PNG image example: https://freepikpsd.com/media/2019/10/alpha-symbol-png-11-Free-PNG-Images-Transparent-1024x731.png

dbalabka avatar Sep 13 '21 20:09 dbalabka

Any hints on fixing this? I'd be happy to contribute.

nielsbosma avatar Jul 19 '22 08:07 nielsbosma

Well let me shed some light on this matter. I think the stacking algorithm we used internally did not support transparency. But there is a parameter called key_color in the clustering algorithm to allow it to skip clustering a certain color. That'd would mean to render the image on a backdrop color you know does not present in the image itself, usaully #F00, #0F0 or #00F and then use that as key.

tyt2y3 avatar Jul 23 '22 06:07 tyt2y3

@tyt2y3 I tried to add key_color to the cmdapp myself but after upgrading to visioncontext 0.7.0 the app just spits out for any conversion:

thread 'main' panicked at 'The two lines are parallel!', C:\Users\niels.cargo\registry\src\github.com-1ecc6299db9ec823\visioncortex-0.7.0\src\path\util.rs:29:9

Would you be open to implement support for transparency? I'd ben happy to pay for your time.

nielsbosma avatar Aug 09 '22 14:08 nielsbosma

+1 for this. Would be fantastic to support transparency.

gillisig avatar Aug 16 '22 11:08 gillisig

Thank you for the interest. I havn't checked the project for a while, but these dev work has a long timeframe, perhaps on the scale of a few months given the situation I am in.

tyt2y3 avatar Aug 18 '22 01:08 tyt2y3

@tyt2y3 did you see @nielsbosma offer to pay you for your time to implement it?

gillisig avatar Aug 18 '22 21:08 gillisig

Yeah I am more time poor than cash poor right now, I'll see whether we can work something out.

tyt2y3 avatar Aug 19 '22 03:08 tyt2y3

@tyt2y3 I've found a developer that can fix this. Are you accepting PRs or should we make our own builds?

nielsbosma avatar Sep 14 '22 08:09 nielsbosma

That's cool. I can review code and answer questions as well.

tyt2y3 avatar Sep 14 '22 09:09 tyt2y3

Hey guys, I have a great news! https://github.com/visioncortex/vtracer/releases/tag/0.5.0

It's surprising this happened on such a niche project: we got a feature request, I joined the chat, a person contributed, I merged and released. It happened over the course of 1 year, but it happened!

Always have faith in open source, I guess?

Thank you everyone who involved, especially @nielsbosma which I assume funded the dev work.

tyt2y3 avatar Oct 09 '22 11:10 tyt2y3