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

SVG to PNG renders inline images incorrectly #917

Closed
KoalaBear84 opened this issue Oct 26, 2021 · 3 comments · Fixed by #920
Closed

SVG to PNG renders inline images incorrectly #917

KoalaBear84 opened this issue Oct 26, 2021 · 3 comments · Fixed by #920
Labels

Comments

@KoalaBear84
Copy link

KoalaBear84 commented Oct 26, 2021

Description

I'm trying to convert an online Meteogram from SVG to PNG. It looks like it doesn't scale the inline (base64) images down correctly.

Example data

Url: https://developer.yr.no/doc/assets/meteogram.svg

Expected:
image

Result:
image

Example code:

using Svg;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

namespace SvgConvert
{
    public class Program
    {
        public static async Task Main()
        {
            HttpClient httpClient = new HttpClient();
            Stream httpSvgStream = await httpClient.GetStreamAsync("https://developer.yr.no/doc/assets/meteogram.svg");
            SvgDocument svgDocument = SvgDocument.Open<SvgDocument>(httpSvgStream);
            Bitmap bitmap = svgDocument.Draw();
            bitmap.Save("Meteogram.png", ImageFormat.Png);
        }
    }
}

Maybe the issue is only scaling and it could be an easy fix. Or there is more info in the <style> tags which isn't parsed/respected.

Used Versions

Windows 10 Pro 21H1 19043.1288
Svg 3.3.0
.NET 6.0 (Also tried .NET Core 3.1 and .NET 5.0)

mrbean-bremen pushed a commit that referenced this issue Oct 30, 2021
* Fixes #917 - SVG to PNG renders inline images incorrectly
* Small refactoring
* Add tests
* Update Release Notes
github-actions bot pushed a commit that referenced this issue Oct 30, 2021
…ING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Fixes #917 - SVG to PNG renders inline images incorrectly
 BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Small refactoring
 BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Add tests
 BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Update Release Notes
@KoalaBear84
Copy link
Author

Thanks @mrbean-bremen 👍
I'll check it when a new release is out.

@mrbean-bremen
Copy link
Member

You'll have to thank @H1Gdev who fixed it 😄

@KoalaBear84
Copy link
Author

Yes indeed, I did saw it 😬

Thanks @H1Gdev 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants