vb.netsvgtype-conversionsvg-transformssvgtopng

Odd transparency issues with SVG converting


I'm trying to convert SVG images to jpeg or png (quality doesn't matter)

I'm using a NuGet package named SVG.

Here's my vb code

Dim svgDocument = Svg.SvgDocument.Open(TextBox2.Text & "\" & filename & ".svg")    ' Replace with correct FileName                                      
                Dim bmp As Bitmap = svgDocument.Draw(100, 100)                            ' Draw Bitmap in any Size you need - for example 12px x 12px                  
                bmp.Save(TextBox2.Text & "\" & "jpeg" & "\" & filename & ".jpeg", ImageFormat.Jpeg)                 ' save Bitmap as PNG-File

The thing that's working wrong is: The background of the text becomes black. Which is not like that when I look at them in a browser.

Deleted

And here is the original file of the SVG

[Deleted][3]

I'm not sure exactly what is wrong, thanks for your time.


Solution

  • Your SVG is full of image elements with base64 encoded PNGs:

    if you paste those:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ4AAACVCAIAAAAmBYPGAAAABmJLR0QA/wD/AP+gvaeTAAAAjElEQVR4nO3BMQEAAADCoPVPbQo/oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAK4G2BYAAb1+fN8AAAAASUVORK5CYII=
    

    into: https://base64.guru/converter/decode/image

    You can see its a black image:

    See F12 network tab:

    Looks like all text are images with a black background