Convert SVG to PNG JPEG using PHP
If you are working on HTML5 then you might have seen the problem of SVG to image option.
Because bydefault HTML5 don’t have any feature to convert SVG to Image format.
Things that are required to convert svg code to Image format
- Java SE (Standard edition) installation and path setting
- Download the batik.jar from the specified below URL
- Next is, sample php code, for the usage details of batik and java with PHP. So download sample code from below URL
- In the above URL you may find the index.php
- Create a new folder in you wamp/xampp and place the index.php inside this folder
- Extract the batik-1.7.zip and place inside the newly created folder
- Change the contents index.php for include details of “batik”
- Rest is all set.
Remeber to set Java BIN and JRE folder path settings properly.
Few things about the sample code (index.php)
- Index.php accepts SVG code as POST parameter
- You may directly pass the SVG code to this variable.
- Make sure you EXEC is available to execute in your PHP instillation
Keep r&d UP !!!