Svg to Jpeg conversion - missing image element

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 - missing image element

Post by eviksza »

When I convert SVG file to Jpeg file, some of the embedded images are missing from the converted Jpeg file.

SVG files can contain embedded images in jpeg or png format. I found that during the conversion only embedded images in jpeg format disappear.

Is it a bug, or jpeg images in SVG files are not supported? Is there a workaround for this issue?

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://dev.w3.org/SVG/profiles/1.1F2/te ... e-04-t.svg

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"));
}
Thank you in advance!
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Svg to Jpeg conversion - missing image element

Post by dlemstra »

It seems that your .svg file is invalid. The content type for one of the embedded images is 'image/jpg' instead of 'image/jpeg'. I found the following bug report for it: https://bugzilla.gnome.org/show_bug.cgi?id=739682. We build our own version of `gdk-pixbuf` under Windows and I just pushed a patch to our repository to also recognize 'image/jpg'. You will be able to read this image in the next version of Magick.NET. I will try to publish that at the end of next month.
.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 - missing image element

Post by eviksza »

Thank you very much!
Post Reply