nplavsic/phpsvg

使用OO PHP编辑和创建SVG文档

0.9.0 2017-12-29 16:47 UTC

This package is auto-updated.

Last update: 2024-08-29 04:48:44 UTC


README

使用OO PHP编辑和创建SVG文档

功能

  • 打开和编辑SVG和SVGZ(GZipped)
  • 生成缩略图或导出为PNG、JPG、GIF、PS、EPS、PDF
  • 支持嵌入式或链接图片。
  • 使用PHP特性:SimpleXMLElement、GZip、Gd、Imagemagick。
  • 可以使用Inkscape导出某些图像格式。

处于开发中。

代码示例

require_once "svglib.php";



$svg = SVGDocument::getInstance( 'resource/apple.svg' ); //open to edit

//$svg = SVGDocument::getInstance( ); //default read to use



$rect = #create a new rect with, x and y position, id, width and heigth, and the style

$rect = SVGRect::getInstance( 0, 5, 'myRect', 228, 185, new SVGStyle( array( 'fill'   => 'red', 'stroke' => 'blue' ) ) );

$svg->addShape( $rect );



$text = SVGText::getInstance( 22, 50, 'myText', 'This is a text', $style );



$svg->asXML('output/output.svg'); //output to svg file

$svg->export('output/output.png'); //export as png

$svg->export('output/thumb32x32.png',32,32); //export thumbnail

$svg->output(); //echo with header to browser

?>