是否有任何工作模块将 SVG图像转换为JPEG或PNG等像素格式?
Take a look at the Batik toolkit. Specifically the rasterizer:
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
If you have imagemagick installed (the tool, not sure how it would work with the PHP package), it can be as simple as:
<?php
`convert infile.svg outfile.jpg`
?>
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
inkscape -z --file=original.svg --export-png=converted.png --export-area-drawing --export-dpi=200
Batch conversion of SVG's to PNG can be achieved as follows :
for i in *.svg;
do inkscape -z --file=$i --export-png=$i.png --export-area-drawing --export-dpi=200;
done
--export-area-drawing : This will only export the drawing area of SVG file and not the whole document area.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.