Svg to Jpeg conversion - empty result

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
eviksza
Posts: 4
Joined: 2016-01-04T09:01:57-07:00
Authentication code: 1151

Svg to Jpeg conversion - empty result

Post by eviksza » 2016-01-06T05:34:13-07:00

When I convert a particular SVG file to JPG, I get an empty JPG file (the whole image is white).

I use the latest version of Magick.NET (v7.0.0.0) with .NET 4.5.

I tried to convert this SVG file to Jpeg:
http://www.filedropper.com/svgphototssp ... elayout100

I use the following code for the conversion:

Code: Select all

MagickReadSettings readSettings = new MagickReadSettings()
{
    Format = MagickFormat.Svg
};

using (MagickImage image = new MagickImage(svgFilePath, readSettings))
{
    image.Format = MagickFormat.Jpeg;

    image.Write(Path.ChangeExtension(svgFilePath, "jpg"));
}
My first guess was that the embedded image in the SVG is invalid, but it is not.
I read the embedded jpeg image data from this SVG file, decoded from base 64, and saved as .jpg file, and I found that it was a valid .jpg file.

Thank you for the help in advance!

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Svg to Jpeg conversion - empty result

Post by dlemstra » 2016-01-06T09:37:04-07:00

It looks like your base64 encoded image is invalid. The library use my Magick.NET is librsvg and this fails to load the image. When you open it in internet explorer you can see what is wrong and when you open it in chrome you get a blurry 'invalid image' image.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

eviksza
Posts: 4
Joined: 2016-01-04T09:01:57-07:00
Authentication code: 1151

Re: Svg to Jpeg conversion - empty result

Post by eviksza » 2016-01-06T10:21:00-07:00

Would it be possible that Magick.NET would put an 'invalid image' image during the conversion in this case? It would be nice to see, that there was an image load error.

Programmatically can I somehow decide whether there was such an error?

Thank you in advance!

User avatar
dlemstra
Posts: 1567
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Svg to Jpeg conversion - empty result

Post by dlemstra » 2016-01-07T01:21:54-07:00

The loading part is handled by librsvg and this library does not report an error. So there is no way to determine that the image failed to load.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

Post Reply