SVG with linked images conversion

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
zharramadar
Posts: 2
Joined: 2019-01-16T09:44:17-07:00
Authentication code: 1152

SVG with linked images conversion

Post by zharramadar » 2019-01-16T09:56:39-07:00

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?

snibgo
Posts: 11474
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: SVG with linked images conversion

Post by snibgo » 2019-01-16T10:13:59-07:00

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.
snibgo's IM pages: im.snibgo.com

zharramadar
Posts: 2
Joined: 2019-01-16T09:44:17-07:00
Authentication code: 1152

Re: SVG with linked images conversion

Post by zharramadar » 2019-01-17T05:54:45-07:00

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?

User avatar
fmw42
Posts: 24770
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG with linked images conversion

Post by fmw42 » 2019-01-17T15:11:41-07:00

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.

User avatar
fmw42
Posts: 24770
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG with linked images conversion

Post by fmw42 » 2019-01-17T15:11:59-07:00

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.

User avatar
fmw42
Posts: 24770
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG with linked images conversion

Post by fmw42 » 2019-01-17T15:12:29-07:00

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.

Post Reply