SVG to PNG, getting blank image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
shoansa
Posts: 15
Joined: 2017-07-18T00:12:17-07:00
Authentication code: 1151

SVG to PNG, getting blank image

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: SVG to PNG, getting blank image

Post 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.
snibgo's IM pages: im.snibgo.com
shoansa
Posts: 15
Joined: 2017-07-18T00:12:17-07:00
Authentication code: 1151

Re: SVG to PNG, getting blank image

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: SVG to PNG, getting blank image

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: SVG to PNG, getting blank image

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: SVG to PNG, getting blank image

Post 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.
Post Reply