Svg for image on request

I have javascript code that generates svg image tags on the fly when a person lands on one of the pages. Im using the d3 library to help make the image. The only problem is that d3 is not fully compatible with IE, and I would like to generate a .png, jpg, gif file or any other image file based on the svg file. Is there a known way to do this? The server-side code is based on PHP, and we use node.js and render.js for a lot of dynamic content.

+5
source share
2 answers

I am using ImageMagick to convert SVG images to PNG images. It works very well.

, :

exec('/usr/bin/convert /path/to/image.svg /path/to/output_image.png');

QR-, libqrencode, .

+5

-, DOM , svg, . jsdom node.js. , D3 svg , , .

, .

SVG PNG, modernizer.js

1) Modernizr.

2) SVG PNG .

( JS):

if (!Modernizr.svg) {
$("#logo").css("background-image", "url(fallback.png)");
}

( CSS):

.no-svg #logo { background-image: url(fallback.png); }
+3

All Articles