Is there any working module to convert a SVG image into a pixel format like JPEG or PNG?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- How to get the background from multiple images by
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
We can also use command line interface such as inkscape to achieve it. Download inkscape from inkscape.org
Open Terminal/command prompt Type command as:
single file conversion
Batch conversion of SVG's to PNG can be achieved as follows :
--export-area-drawing : This will only export the drawing area of SVG file and not the whole document area.
If you're using PEAR you can the XML_svg2image package (http://pear.php.net/package/XML_svg2image/). If not you should take a look at ImageMagick command line tool (http://www.imagemagick.org/script/command-line-tools.php). The convert program is quite simple to use : http://www.imagemagick.org/script/convert.php#usage
Take a look at the Batik toolkit. Specifically the rasterizer:
http://xmlgraphics.apache.org/batik/tools/rasterizer.html
If you have imagemagick installed (the tool, not sure how it would work with the PHP package), it can be as simple as: