Download the PHP package msztorc/svg-convert without Composer
On this page you can find all versions of the php package msztorc/svg-convert. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download msztorc/svg-convert
More information about msztorc/svg-convert
Files in msztorc/svg-convert
Package svg-convert
Short Description Various helpers to convert SVG files to other formats including PNG & PDF.
License MIT
Informations about the package svg-convert
svg-convert
Various helpers to convert SVG files to other formats, especially PNG and PDF. Package includes CLI (phantomjs script) to render and php adapter to manipulate and convert SVG format using phantomjs or rsvg-convert (librsvg).
Install PhantomJS
Before installing PhantomJS, you will need to install some required packages on your system. You can install all of them with the following commands:
sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y
Next, you will need to download the PhantomJS. You can download the latest stable version of the PhantomJS from their official website.
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
Extract the downloaded archive file to desired system location:
sudo tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
Next, create a symlink of PhantomJS binary file to systems bin directory:
sudo ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/
Use psvg-convert script globally
Install RSVG (only if you want to convert svg using librsvg)
sudo apt-get update
sudo apt-get install libcairo2-dev libspectre-dev librsvg2-dev \ libpoppler-glib-dev librsvg2-bin
Examples
Convert SVG to PNG format using PhantomJS CLI script
psvg-convert inputfile.svg outputfile.png
Usage
psvg-convert svgfile outputfile [--width=800 --height=600 --zoom=2.5 --format=png|pdf]
Convert SVG file in PHP
Initializing method with phantomjs
argument when you want use to PhantomJS engine
or if you want to use rsvg-convert
Manipulate and convert SVG file in PHP
Other useful methods
Open file
Set zoom
Set size
Set output format
Display file
Download file
Save file
Image tests
All images you can find in unit tests folder.
PhantomJS | rsvg-convert |
---|---|
SVG manipulation
Create gif using imagemagick
convert -loop 0 -delay 25 ubuntu1.png ubuntu2.png ubuntu3.png ubuntu.gif
License
MIT