SVG libraries for PHP
- php-svg is a pure PHP library with no required extensions: build SVG documents in code, parse SVG files into a tree you can change, and rasterize simple SVG to PNG or JPEG with GD. Its renderer is basic; use it mainly to generate and edit SVG.
- Imagick is the PHP extension for ImageMagick. It converts SVG to PNG, JPEG, WebP or PDF with ImageMagick’s renderer (its internal MSVG or librsvg, depending on the build). Use it for server-side conversion when the extension is available.
To sanitize SVG uploads before serving them, use svg-sanitizer (enshrined/svg-sanitize on Packagist).
- Imagick Imagick is the PHP extension for ImageMagick. How to install it, convert SVG to PNG, JPEG and PDF, set the resolution and size, keep transparency.
- php-svg php-svg (meyfa/php-svg) creates, parses, edits and rasterizes SVG in pure PHP. How to install it, generate SVG, load and modify an SVG file.