xyproto / png2svg

:twisted_rightwards_arrows: Convert small PNG images to SVG Tiny 1.2
BSD 3-Clause "New" or "Revised" License
314 stars 38 forks source link

Generated SVGs are semitransparent #1

Closed Tachi107 closed 4 years ago

Tachi107 commented 4 years ago

Hi, first of all thanks for this repo! I tried to convert my profile picture to see how this tool worked, and I noticed that some SVG viewers render the image as if it were semitransparent (the input PNG is not transparent). For example, Xfce's thumbnails and this site see the transparentness, but Chromium's SVG viewer does not. Do you think there's a solution to this behavior?

xyproto commented 4 years ago

Hi! Thanks for trying out png2svg.

I tried converting your profile image, and (unoptimized) it resulted in a 6,2M SVG image, with no transparent rectangles. Firefox shows it correctly here. Chromium as well. (But they both take a while to draw it).

These types of large SVG images that are constructed of tons of little rectangles are quite unusual, so they are likely to uncover bugs in several different applications.

Since both Firefox and Chromium gets it right, it's tempting to say that this is a bug with the other SVG rendering engines.

Inkscape renders this image incorrectly to PNG. Perhaps it's a matter of how they interpret data that is left out of the SVG document?

I guess it boils down to the SVG standard. If the resulting SVG document is not following the standard, then there's an issue with png2svg, and I will try to fix it.

Tachi107 commented 4 years ago

I think that the problem pops up especially with low resolutions. I'm trying to set a BIMI image for my email domain. BIMI requires that the SVG follows the SVG Tiny Portable/Secure profile, that is just a subset of SVG Tiny (you can't have animations, scripts...). A 6 MB SVG image would be overkill, so I resized my profile picture down to 128x, and converted it with your tool. At this resolution, when scaling the image, the distance between one rectangle and another is filled with nothing, showing the colors behind the image

xyproto commented 4 years ago

Could you please attach the SVG?

xyproto commented 4 years ago

Even with <rect stroke-width="0" instead of just <rect, Inkscape renders the resulting SVG incorrectly.

Since GIMP, Firefox, Chromium and ImageMagick renders the SVG file correctly, and the SVG document itself contains no transparency, my conclusion is that this is a bug with Inkscape, Eog and the BIMI web application.

Tachi107 commented 4 years ago

Could you please attach the SVG?

https://mail.paoloap.ml/Tachi.svg

Since GIMP, Firefox, Chromium and ImageMagick renders the SVG file correctly, and the SVG document itself contains no transparency, my conclusion is that this is a bug with Inkscape, Eog and the BIMI web application.

Yeah most of the time it is rendered correctly, but not when scaled, expecially when scaled up (even in Chromium)