PHP Classes
elePHPant
Icontem

PHP SVG Magick Library: Compose vectorial graphics in SVG format

Recommend this page to a friend!
  Info   View files Example   View files View files (201)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-06-11 (5 months ago) RSS 2.0 feedStarStarStarStarStar 80%Total: 135 This week: 1All time: 8,565 This week: 607Up
Version License PHP version Categories
svgmagick 1.0.1Custom (specified...5PHP 5, Graphics, Traits
Description Author

This package can compose vectorial graphics in SVG format.

It provides classes that can compose the definition of different types of vectorial graphic elements as a DOM XML document.

Currently it supports the main SVG container, shapes, text, fonts, filters, gradients, animations and many more.

The composed SVG document is returned as a XML string.

Name: Edgar Asatryan <contact>
Classes: 4 packages by
Country: Armenia Armenia
Age: ???
All time rank: 31658 in Armenia Armenia
Week rank: 176 Up2 in Armenia Armenia Up
Innovation award
Innovation award
Nominee: 1x

Details

SVGMagick Build Status Scrutinizer Code Quality Code Coverage

The full SVG implementation on PHP. Currently, the library contains the full SVG specification. SVGMagick also contains a number of useful methods for working with filter, the gradient (e.g. UniformGradient with direction and position) and the transformation of the SVG basic shapes (e.g. polygon, rect, polyline) in the path. SVGMagick does not yet have a stable API, so everything can change at any time.

Hope to read feedbacks and suggestions from community about SVGMagick to make it better.

Requirements

  • php >= 5.4.0
  • ext-dom (enabled by default)

Installation

The suggested installation method is via composer:

$ composer require nstdio/svg: "dev-master"

or add

"nstdio/svg": "dev-master"

to the require section of your composer.json file.

Basic Usage

Every SVG tag has corresponding class in SVGMagick. What is needed for the creation of SVGMagick object? You have to pass as the first parameter of the constructor is the parent object. So you don't need to explicitly call append on parent object.

use nstdio\svg\container\Defs;
use nstdio\svg\container\SVG;
use nstdio\svg\gradient\LinearGradient;

// ...

$svg = new SVG();
$defs = new Defs($svg); // <defs> will be appended in <svg>.
$gradient = new LinearGradient($defs) // <linearGradient> will be appended in <defs>

All classes are subject to this rule except for SVG.

Shapes


use nstdio\svg\container\SVG;
use nstdio\svg\shape\Rect;

// ...

$svg = new SVG(); // by default width = 640, height = 480.

$rect = new Rect($svg, 120, 300, 3, 3); // creating Rect object and appending <rect> element to <svg>

// You have two way to set <rect> element attributes.

// Use magic methods. Any attribute can be setted using magic setter.
// Note that for setting dash-separated attribute you must use camelCase.
// For setting stroke-linecap you must set strokeLinecap propery of corresponding object.

$rect->rx = 5;
$rect->ry = 5;
$rect->stroke = 'darkgreen';
$rect->fill = 'limegreen';
$rect->strokeWidth = 1.5;  // In this particular case strokeWidth will be converted into stroke-width.

// Or use apply method.
$rect->apply(['stroke' => 'darkgreen', 'fill' => 'limegreen', 'stroke-width' => 1.5]);
$rect->setBorderRadius(5); // setting rx and ry at once.

(new Circle($svg, 75, 200, 70))->apply([
    'fill' => '#001f3f',
    'fillOpacity' => 0.6,
    'stroke' => '#FF851B',
    'strokeWidth' => 5,
]);

echo $svg; // or $svg->draw() to get svg structure;

Result

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="640" height="480" version="1.1" viewBox="0 0 640 480">
    <rect height="120" width="300" x="3" y="3" rx="5" ry="5" stroke="darkgreen" fill="limegreen" stroke-width="1.5"></rect>
    <circle cx="75" cy="200" r="70" fill="#001f3f" fill-opacity="0.6" stroke="#FF851B" stroke-width="5"></circle>
</svg>
  Files folder image Files  
File Role Description
Files folder imageexample (18 files)
Files folder imagesrc (1 directory)
Files folder imagetests (1 file, 2 directories)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file blend.php Example Example script
  Accessible without login Plain text file colorMatrix.php Example Example script
  Accessible without login Plain text file componentTransfer.php Example Example script
  Accessible without login Plain text file cubicBezierBox.php Example Example script
  Accessible without login Plain text file diffuseLightingCustom.php Example Example script
  Accessible without login Plain text file filterGaussian.php Example Example script
  Accessible without login Plain text file gradient.php Example Example script
  Accessible without login Plain text file import.php Aux. Auxiliary script
  Accessible without login Plain text file light.php Example Example script
  Accessible without login Plain text file motion.php Example Example script
  Accessible without login Plain text file pathBox.php Example Example script
  Accessible without login Plain text file pattern.php Example Example script
  Accessible without login Plain text file quadraticBezierBox.php Example Example script
  Accessible without login Plain text file set.php Example Example script
  Accessible without login Plain text file shadow.php Example Example script
  Accessible without login Plain text file shapeLighting.php Example Example script
  Accessible without login Plain text file shapes.php Example Example script
  Accessible without login Plain text file transform.php Example Example script

  Files folder image Files  /  src  
File Role Description
Files folder imagesvg (9 files, 15 directories)

  Files folder image Files  /  src  /  svg  
File Role Description
Files folder imageanimation (6 files)
Files folder imageattributes (18 files)
Files folder imagecontainer (11 files)
Files folder imagedesc (4 files)
Files folder imagefilter (24 files)
Files folder imagefont (10 files)
Files folder imagegradient (6 files)
Files folder imageimport (2 files)
Files folder imagelight (4 files)
Files folder imageoutput (8 files)
Files folder imageshape (11 files)
Files folder imagetext (10 files)
Files folder imagetraits (4 files)
Files folder imageutil (4 files, 1 directory)
Files folder imagexml (4 files)
  Plain text file Animatable.php Class Class source
  Plain text file Base.php Class Class source
  Plain text file ElementFactoryInterface.php Class Class source
  Plain text file ElementInterface.php Class Class source
  Plain text file ElementStorage.php Class Class source
  Plain text file Filterable.php Class Class source
  Plain text file GradientInterface.php Class Class source
  Plain text file SVGElement.php Class Class source
  Plain text file XMLDocumentInterface.php Class Class source

  Files folder image Files  /  src  /  svg  /  animation  
File Role Description
  Plain text file Animate.php Class Class source
  Plain text file AnimateMotion.php Class Class source
  Plain text file AnimateTransform.php Class Class source
  Plain text file BaseAnimation.php Class Class source
  Plain text file MPath.php Class Class source
  Plain text file Set.php Class Class source

  Files folder image Files  /  src  /  svg  /  attributes  
File Role Description
  Plain text file Animation.php Class Class source
  Plain text file AnimationAddition.php Class Class source
  Plain text file AnimationEvent.php Class Class source
  Plain text file AnimationTarget.php Class Class source
  Plain text file AnimationTiming.php Class Class source
  Plain text file AnimationValue.php Class Class source
  Plain text file ConditionalProcessing.php Class Class source
  Plain text file Core.php Class Class source
  Plain text file DocumentEvent.php Class Class source
  Plain text file ExternalResourcesRequired.php Class Class source
  Plain text file FilterPrimitive.php Class Class source
  Plain text file FullyAnimatable.php Class Class source
  Plain text file GraphicalEvent.php Class Class source
  Plain text file Presentation.php Class Class source
  Plain text file Styleable.php Class Class source
  Plain text file TransferFunction.php Class Class source
  Plain text file Transformable.php Class Class source
  Plain text file XLink.php Class Class source

  Files folder image Files  /  src  /  svg  /  container  
File Role Description
  Plain text file A.php Class Class source
  Plain text file Container.php Class Class source
  Plain text file ContainerInterface.php Class Class source
  Plain text file Defs.php Class Class source
  Plain text file G.php Class Class source
  Plain text file Marker.php Class Class source
  Plain text file Mask.php Class Class source
  Plain text file Pattern.php Class Class source
  Plain text file SVG.php Class Class source
  Plain text file Swtch.php Class Class source
  Plain text file Symbol.php Class Class source

  Files folder image Files  /  src  /  svg  /  desc  
File Role Description
  Plain text file Desc.php Class Class source
  Plain text file Descriptive.php Class Class source
  Plain text file Metadata.php Class Class source
  Plain text file Title.php Class Class source

  Files folder image Files  /  src  /  svg  /  filter  
File Role Description
  Plain text file BaseFilter.php Class Class source
  Plain text file Blend.php Class Class source
  Plain text file ColorMatrix.php Class Class source
  Plain text file ComponentTransfer.php Class Class source
  Plain text file Composite.php Class Class source
  Plain text file ConvolveMatrix.php Class Class source
  Plain text file DiffuseLighting.php Class Class source
  Plain text file DisplacementMap.php Class Class source
  Plain text file Filter.php Class Class source
  Plain text file Flood.php Class Class source
  Plain text file Func.php Class Class source
  Plain text file FuncA.php Class Class source
  Plain text file FuncB.php Class Class source
  Plain text file FuncG.php Class Class source
  Plain text file FuncR.php Class Class source
  Plain text file GaussianBlur.php Class Class source
  Plain text file Image.php Class Class source
  Plain text file Merge.php Class Class source
  Plain text file MergeNode.php Class Class source
  Plain text file Morphology.php Class Class source
  Plain text file Offset.php Class Class source
  Plain text file SpecularLighting.php Class Class source
  Plain text file Tile.php Class Class source
  Plain text file Turbulence.php Class Class source

  Files folder image Files  /  src  /  svg  /  font  
File Role Description
  Plain text file BaseFont.php Class Class source
  Plain text file Font.php Class Class source
  Plain text file FontFace.php Class Class source
  Plain text file FontFaceFormat.php Class Class source
  Plain text file FontFaceName.php Class Class source
  Plain text file FontFaceSrc.php Class Class source
  Plain text file FontFaceUri.php Class Class source
  Plain text file HKern.php Class Class source
  Plain text file MissingGlyph.php Class Class source
  Plain text file VKern.php Class Class source

  Files folder image Files  /  src  /  svg  /  gradient  
File Role Description
  Plain text file Direction.php Class Class source
  Plain text file Gradient.php Class Class source
  Plain text file LinearGradient.php Class Class source
  Plain text file RadialGradient.php Class Class source
  Plain text file Stop.php Class Class source
  Plain text file UniformGradient.php Class Class source

  Files folder image Files  /  src  /  svg  /  import  
File Role Description
  Plain text file Importer.php Class Class source
  Plain text file ImportInterface.php Class Class source

  Files folder image Files  /  src  /  svg  /  light  
File Role Description
  Plain text file BaseLight.php Class Class source
  Plain text file DistantLight.php Class Class source
  Plain text file PointLight.php Class Class source
  Plain text file SpotLight.php Class Class source

  Files folder image Files  /  src  /  svg  /  output  
File Role Description
  Plain text file FileOutput.php Class Class source
  Plain text file FileOutputInterface.php Class Class source
  Plain text file ImageOutput.php Class Class source
  Plain text file ImageOutputInterface.php Class Class source
  Plain text file IOFormat.php Class Class source
  Plain text file Output.php Class Class source
  Plain text file OutputInterface.php Class Class source
  Plain text file SVGOutputInterface.php Class Class source

  Files folder image Files  /  src  /  svg  /  shape  
File Role Description
  Plain text file Circle.php Class Class source
  Plain text file Ellipse.php Class Class source
  Plain text file Line.php Class Class source
  Plain text file Path.php Class Class source
  Plain text file PathBounds.php Class Class source
  Plain text file Polygon.php Class Class source
  Plain text file Polyline.php Class Class source
  Plain text file Rect.php Class Class source
  Plain text file RoundedShape.php Class Class source
  Plain text file Shape.php Class Class source
  Plain text file ShapeInterface.php Class Class source

  Files folder image Files  /  src  /  svg  /  text  
File Role Description
  Plain text file AltGlyph.php Class Class source
  Plain text file AltGlyphDef.php Class Class source
  Plain text file AltGlyphItem.php Class Class source
  Plain text file BaseText.php Class Class source
  Plain text file Glyph.php Class Class source
  Plain text file GlyphRef.php Class Class source
  Plain text file Text.php Class Class source
  Plain text file TextPath.php Class Class source
  Plain text file TRef.php Class Class source
  Plain text file TSpan.php Class Class source

  Files folder image Files  /  src  /  svg  /  traits  
File Role Description
  Plain text file ChildTrait.php Class Class source
  Plain text file ElementTrait.php Class Class source
  Plain text file StyleTrait.php Class Class source
  Plain text file TransformTrait.php Class Class source

  Files folder image Files  /  src  /  svg  /  util  
File Role Description
Files folder imagetransform (6 files)
  Plain text file Bezier.php Class Class source
  Plain text file Identifier.php Class Class source
  Plain text file Inflector.php Class Class source
  Plain text file KeyValueWriter.php Class Class source

  Files folder image Files  /  src  /  svg  /  util  /  transform  
File Role Description
  Plain text file Packer.php Class Class source
  Plain text file PackerInterface.php Class Class source
  Plain text file Transform.php Class Class source
  Plain text file TransformInterface.php Class Class source
  Plain text file TransformMatcher.php Class Class source
  Plain text file TransformMatcherInterface.php Class Class source

  Files folder image Files  /  src  /  svg  /  xml  
File Role Description
  Plain text file DOMElementWrapper.php Class Class source
  Plain text file DOMNode.php Class Class source
  Plain text file DOMWrapper.php Class Class source
  Plain text file NotImplementedException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imagesvg (7 files, 9 directories)
Files folder imageutil (3 files, 1 directory)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script

  Files folder image Files  /  tests  /  svg  
File Role Description
Files folder imageanimation (3 files)
Files folder imagecontainer (1 file)
Files folder imagedesc (1 file)
Files folder imagefilter (3 files)
Files folder imagegradient (3 files)
Files folder imageimport (1 file)
Files folder imagelight (1 file)
Files folder imageshape (9 files)
Files folder imagetext (1 file)
  Plain text file ElementStorageTest.php Class Class source
  Plain text file SVGChildTest.php Class Class source
  Plain text file SVGContextTestCase.php Class Class source
  Plain text file SVGElementCopyTest.php Class Class source
  Plain text file SVGFileOutputTest.php Class Class source
  Plain text file SVGOutputHeadersTest.php Class Class source
  Plain text file SVGTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  animation  
File Role Description
  Plain text file AnimateTransformTest.php Class Class source
  Plain text file MPathTest.php Class Class source
  Plain text file SetTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  container  
File Role Description
  Plain text file PatternTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  desc  
File Role Description
  Plain text file DescriptiveTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  filter  
File Role Description
  Plain text file ColorMatrixTest.php Class Class source
  Plain text file ComponentTransferTest.php Class Class source
  Plain text file FilterTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  gradient  
File Role Description
  Plain text file DirectionTest.php Class Class source
  Plain text file GradientTest.php Class Class source
  Plain text file UniformGradientTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  import  
File Role Description
  Plain text file ImporterTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  light  
File Role Description
  Plain text file BaseLightTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  shape  
File Role Description
  Plain text file EllipseTest.php Class Class source
  Plain text file LineTest.php Class Class source
  Plain text file PathBoundsTest.php Class Class source
  Plain text file PathTest.php Class Class source
  Plain text file PolygonTest.php Class Class source
  Plain text file PolylineTest.php Class Class source
  Plain text file RectTest.php Class Class source
  Plain text file ShapeFilterTest.php Class Class source
  Plain text file ShapeUniformGradientTest.php Class Class source

  Files folder image Files  /  tests  /  svg  /  text  
File Role Description
  Plain text file TextTest.php Class Class source

  Files folder image Files  /  tests  /  util  
File Role Description
Files folder imagetransform (2 files)
  Plain text file IdentifierTest.php Class Class source
  Plain text file InflectorTest.php Class Class source
  Plain text file KeyValueWriterTest.php Class Class source

  Files folder image Files  /  tests  /  util  /  transform  
File Role Description
  Plain text file TransformCompactTest.php Class Class source
  Plain text file TransformTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:135
This week:1
All time:8,565
This week:607Up
User Ratings User Comments (2)
 All time
Utility:100%StarStarStarStarStarStar
Consistency:100%StarStarStarStarStarStar
Documentation:100%StarStarStarStarStarStar
Examples:100%StarStarStarStarStarStar
Tests:-
Videos:-
Overall:80%StarStarStarStarStar
Rank:26
 
No result screens - its bad.
9 months ago (KillerDr)
80%StarStarStarStarStar
No result screens - its bad.
9 months ago (KillerDr)
80%StarStarStarStarStar