Page 1 of 1

SVG with linked images conversion

Posted: 2019-01-16T09:56:39-07:00
by zharramadar
Hi,

I'm having an issue converting SVG files with linked images. Embedded images work fine though.
I have in a SVG file I'm testing the following line:

<image xlink:href='C:/Data/0160019002-13.png' x='6mm' y='96mm' height='8mm' width='33.7mm' />

When opening the SVG file using a browser, the image appears fine, but after converting it to PDF or PNG with Magick.NET and opening them, the image does not appear in the resulting file.

I'm using the Magick.NET-Q8-x64 NuGet package, running it in a Windows 10 machine, with the following code:

Code: Select all

	ImageMagick.MagickReadSettings rs = new ImageMagick.MagickReadSettings()
	{
		TextEncoding = Encoding.UTF32
	};
	
	ImageMagick.MagickImage i = new ImageMagick.MagickImage(sourcefile, rs);
	i.Write(destfile, ImageMagick.MagickFormat.Pdf);
 
I tried also to change C:/Data/0160019002-13.png to file:///C:/Data/0160019002-13.png or C:\Data\0160019002-13.png, to no avail.

Anyone knows what can be done so those linked images get rendered in the PDF file I'm saving?

Re: SVG with linked images conversion

Posted: 2019-01-16T10:13:59-07:00
by snibgo
What is rendering your SVG? I expect the external Inkscape delegate works fine, but the internal MSVG delegate may not. I'm not sure about the internal RSVG delegate.

Re: SVG with linked images conversion

Posted: 2019-01-17T05:54:45-07:00
by zharramadar
It is rendering all text and other elements, in the right position, just the linked images are missing.

It is better if I do not shell from C# to call an external app to perform the conversion, it is best to keep all internal in the application in my case.
I can also read all external images and change the links to embed them before processing the SVG, but that's not optimal as well.

Any ideas on how to make this work?

Re: SVG with linked images conversion

Posted: 2019-01-17T15:11:41-07:00
by fmw42
What is your SVG renderer? ImageMagick could be using inkscape if it is on your system or the RSVG delegate or its own internal MSVG/XML renderer, in order of best to worst.

If you have inkscape on your system, Imagemagick will use it automatically. Otherwise, check

convert -list format

and look at the end of the SVG line. It will say either RSVG if you have that delegate installed or XML for the ImageMagick internal renderer. The latter may not do so well and could be the cause of your issue.

Re: SVG with linked images conversion

Posted: 2019-01-17T15:11:59-07:00
by fmw42
What is your SVG renderer? ImageMagick could be using inkscape if it is on your system or the RSVG delegate or its own internal MSVG/XML renderer, in order of best to worst.

If you have inkscape on your system, Imagemagick will use it automatically. Otherwise, check

convert -list format

and look at the end of the SVG line. It will say either RSVG if you have that delegate installed or XML for the ImageMagick internal renderer. The latter may not do so well and could be the cause of your issue.

Re: SVG with linked images conversion

Posted: 2019-01-17T15:12:29-07:00
by fmw42
What is your SVG renderer? ImageMagick could be using inkscape if it is on your system or the RSVG delegate or its own internal MSVG/XML renderer, in order of best to worst.

If you have inkscape on your system, Imagemagick will use it automatically. Otherwise, check

convert -list format

and look at the end of the SVG line. It will say either RSVG if you have that delegate installed or XML for the ImageMagick internal renderer. The latter may not do so well and could be the cause of your issue.