Processing SVG with a namespace

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Processing SVG with a namespace

Post by honyk »

Hello Everyone,

when a namespace is used in my SVG file, I am getting error

Code: Select all

@ error/mvg.c/ReadMVGImage/184

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<svg:svg xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:svg="http://www.w3.org/2000/svg" version="1.1" width="300" height="100">
   <svg:rect width="300" height="100" style="fill:red"/>
</svg:svg>
It works fine when no namespace is used, but I need it there for placing my svg into another XML...
Is there any easy workaround?

Regards,
Jan

IM 6.6.5-7 2010-11-06 Q16 Win7 64-bit
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Processing SVG with a namespace

Post by anthony »

What method os IM using to convert SVG to raster?

Code: Select all

  convert -list format | grep SVG
In my own case I get...
SVG SVG rw+ Scalable Vector Graphics (RSVG 2.26.3)
which means I am using the external RSVG library rather that the internal MSVG interface.

The RSVG is more complete than MSVG and as such generally preferred.

For more detail see Im Examples, Drawing, SVG Input Drivers: RSVG vs MSVG
http://www.imagemagick.org/Usage/draw/#svg_drivers
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Re: Processing SVG with a namespace

Post by honyk »

This is what I am getting:
MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (XML 2.4.19)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.4.19)

I've read something about RSVG in 'usage' pages, but this text seemed to me a bit obsolete as it is not listed in the above result at all. I've found on the web only very old version of RSVG [1] so I've though it was replaced by something else (XML 2.4.19).
____________
[1] http://librsvg.sourceforge.net/
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Re: Processing SVG with a namespace

Post by honyk »

Ok, I've found another pages http://library.gnome.org/devel/rsvg/stable/ where more recent version is mentioned as part of GNOME project. Is there any chance to get this updated rsvg library for Window platform? And compile IM with it succesfully on this platform? Or is it available for *nix only? I cannot find any link with more details there...

There are couple of another issues in default SVG->PNG conversion so I think I really need something more reliable. RSVG capabilities seems to be promising.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Processing SVG with a namespace

Post by anthony »

Sorry I can't help you with regards to Windows. The text isn't out of date, just more linux centric.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Re: Processing SVG with a namespace

Post by honyk »

Anyone that wouldn't mind converting my test SVG file [1] into PNG with rsvg-enhanced ImageMagick and making the result public via imageshack.us or other free picture sharing server? I would be grateful a lot.
_________
[1] http://bilyujezd.cz/other/test.svg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Processing SVG with a namespace

Post by anthony »

An alternative is to display the SVG in a web browser!
Firefox I know fully supports SVG, but I believe IE I believe does to.
You can then do a screen capture to grab the results.

Following the you gave however did not directly produce a SVG image, just the raw SVG text as the web server supplying that link declared it as type "text/plain". After saving and opening the file in firefox the image was visible -- all boxes and stuff.

I uploaded your test.svg file to my 'DropBox' public area...
https://dl.dropbox.com/u/9500683/test.svg
Drop box did declare the file the above link points to, as being type "image/svg+xml" and so does display as a SVG image in my browser.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Re: Processing SVG with a namespace

Post by honyk »

Thanks for your effort. I have no chance to change the list of supported mime types on that server.
What I am trying to test is that background image (flower.jpg, unfortunately not copied to your server) placed into the given area using the special attribute preserveAspectRatio="xMidYMax slice" and then enhanced by grey filter.
This SVG can be converted into PNG as expected via Batik, but Java is not supported on the targer web server. So I try to find any PHP solution (where IM is used very often). As this web server runs on Linux, I don't need Windows version of rsvg and even to have IM compiled with it for that platform, but I'd just like to know if the special rsvg enhanced linux version can do it. If so, I would then tried replacing that default IM version with the enhanced one (I hope it can be done somehow).
I really need PNG/JPEG output as the SVG support in browsers is limited (http://www.codedread.com/svg-support.php). And the solution based on http://code.google.com/p/svgweb/ doesn't support all the required features yet.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Processing SVG with a namespace

Post by anthony »

If the rsvg package is installed you can use the "rsvg" comamnd to convert the SVG, and then let IM take over from there. This is essentially what the RSVG coder does (though via the rsvg library).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
honyk
Posts: 11
Joined: 2010-11-15T11:28:00-07:00
Authentication code: 8675308

Re: Processing SVG with a namespace

Post by honyk »

Thanks for the RSVG tip. Finally I've found this procedure how to test rsvg functionality on Windows:
http://meta.wikimedia.org/wiki/Talk:SVG ... of_RSVG.3F
It is even sufficient just to put the rsvg-convert.exe in GIMP's 'bin' folder and into the cmdline write something like

Code: Select all

rsvg_convert -o C:\output.png C:\input.svg
I see in the output what I want so I'll go on this way.
Post Reply