Converting a "complex" SVG to a PNG
Posted: 2013-12-11T02:08:34-07:00
I'm quite new to ImageMagick and want to convert complex SVGs to PNG. I've tested several SVGs with ImageMagick and Batik.
Commands I used:
ImageMagick:
Batik:
Results:
Cube (included SVG + text):
SVG: https://devpublic.blob.core.windows.net ... /Empty.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (not acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Shapes (image + mask):
SVG: https://devpublic.blob.core.windows.net ... shapes.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (not acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Simple (2 circles + image):
SVG: https://devpublic.blob.core.windows.net ... Simple.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Complex (circle + image + mask + displacement map):
SVG: https://devpublic.blob.core.windows.net ... vgTest.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (almost acceptable, the displacement map don't work)
Problem
ImageMagick
All I want to do is to convert a SVG to PNG with C# .NET. Possible solutions are using ImageMagick.NET (http://imagemagick.codeplex.com/) OR the online service Blitline (uses ImageMagick -> http://blitline.com/), but it should be possible to convert the given SVG (see above) to PNG.
Batik
Using Batik is quite cumbersome, because I would need to start a process which also starts the JVM so that the JAR file can be executed (resource intensive (RAM, CPU)).
My question is, is there any ImageMagick solution to achieve the same output as with Batik (Note: I can't change the input SVG)? Following things seem not work quite properly: SVGText with text-anchor="middle", mask and including other SVGs.
Commands I used:
ImageMagick:
Code: Select all
E:\xxx\ImageMagick-6.8.7-Q16>convert -size 400x400 -background none "E:\xxx\svgTestSimple.svg" "E:\xxx\svgTestSimple_magick.png"
Code: Select all
E:\xxx\batik-1.7>java -jar batik-rasterizer.jar -w 400 -h 400 "E:\xxx\svgTestSimple.svg" -d "E:\xxx\svgTestSimple_batik.png"
Cube (included SVG + text):
SVG: https://devpublic.blob.core.windows.net ... /Empty.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (not acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Shapes (image + mask):
SVG: https://devpublic.blob.core.windows.net ... shapes.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (not acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Simple (2 circles + image):
SVG: https://devpublic.blob.core.windows.net ... Simple.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (acceptable)
Complex (circle + image + mask + displacement map):
SVG: https://devpublic.blob.core.windows.net ... vgTest.svg
ImageMagick: https://devpublic.blob.core.windows.net ... magick.png (acceptable)
Batik: https://devpublic.blob.core.windows.net ... _batik.png (almost acceptable, the displacement map don't work)
Problem
ImageMagick
All I want to do is to convert a SVG to PNG with C# .NET. Possible solutions are using ImageMagick.NET (http://imagemagick.codeplex.com/) OR the online service Blitline (uses ImageMagick -> http://blitline.com/), but it should be possible to convert the given SVG (see above) to PNG.
Batik
Using Batik is quite cumbersome, because I would need to start a process which also starts the JVM so that the JAR file can be executed (resource intensive (RAM, CPU)).
My question is, is there any ImageMagick solution to achieve the same output as with Batik (Note: I can't change the input SVG)? Following things seem not work quite properly: SVGText with text-anchor="middle", mask and including other SVGs.