Page 1 of 1

SVG to PNG, getting blank image

Posted: 2019-01-03T05:37:44-07:00
by shoansa
Hi,

I am trying to convert a SVG to PNG. SVG has three Linked images, after converting that SVG I get blank PNG or sometimes only one linked image get rendered in PNG.
Due to some reasons, I can not use embedded(base64) image in the SVG. Below are the system and IM details.

Windows 10
IM = ImageMagick-7.0.8-Q16 and ImageMagick-6.9.1-Q16-HDRI (both versions)
IM SVG reader (RSVG 2.40.1)

Below is the SVG XML. Any image can be used in href links.

Code: Select all

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"[]>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="1024" height="161" x="0" y="0" xml:space="preserve">
  <desc>Created with Fabric.js 1.4.12</desc>
  <defs></defs>
<g transform="translate(195.5 34.88)">
<image xlink:href="logo.png" x="-34" y="-34" width="58" height="58"></image>
</g> 

<g transform="translate(260.5 30.82)">
<image xlink:href="text.png" x="-62" y="-46"></image>
</g>

<g transform="translate(512 80.5)">
<image xlink:href="bg.png" x="-512" y="-80.5"></image>
</g>
</svg>
Please any help to find the solution.

Thanks in advance

Re: SVG to PNG, getting blank image

Posted: 2019-01-03T05:43:09-07:00
by snibgo
See a recent thread on embedded images in SVG. The problem could be that a temporary copy of the SVG is written to /tmp or %TEMP%, but your embedded images are not there. A workaround is to set Magick's temporary path to the directory that contains the SVG.

Re: SVG to PNG, getting blank image

Posted: 2019-01-03T22:54:58-07:00
by shoansa
Thanks for your response.
I changed the IM temp path to SVG directory but still getting the same result. I am unable to find the thread related the same.
Any other way to get the desired output? From Inkscape am getting the output but due to some other limitation I can't use that.

Re: SVG to PNG, getting blank image

Posted: 2019-01-04T00:06:32-07:00
by fmw42
I get a non-empty image on IM 7.0.8.23 Q16 Mac OSX with inkscape @0.92.3 called by Imagemagick.

Code: Select all

magick test.svg test.png
With the basic Imagemagick MSVG renderer, I get an error

Code: Select all

magick MSVG:test.svg test2.png
magick: Unsupported version '1.1'

I have not testes RSVG delegate with Imagemagick.

Re: SVG to PNG, getting blank image

Posted: 2019-01-04T06:19:24-07:00
by snibgo
Like Fred, using MSVG gives the strange message "magick: Unsupported version '1.1'". Changing the first line to...

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
... fixes that problem, and seems to give a good result.

Re: SVG to PNG, getting blank image

Posted: 2019-01-04T08:19:25-07:00
by magick
The exception is thrown by the libxml2 delegate library. It only supports XML version 1.0. Its a warning so it can be safely ignored.