Page 1 of 1

Svg to Jpeg conversion - missing image element

Posted: 2016-01-05T02:34:18-07:00
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!

Re: Svg to Jpeg conversion - missing image element

Posted: 2016-01-05T05:12:46-07:00
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.

Re: Svg to Jpeg conversion - missing image element

Posted: 2016-01-06T03:21:42-07:00
by eviksza
Thank you very much!