PHP Classes

PHP SVG to PNG: Render a SVG graphic as a PNG image

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStar 26%Total: 2,378 All time: 1,639 This week: 524Up
Version License PHP version Categories
svg2png 1.0Artistic License4.2Graphics
Description 

Author

This class can be used to render a SVG graphic as a PNG image using Inkscape program.

It takes a SVG file and calls the Inkscape program to convert it to an image file in the PNG format.

Innovation Award
PHP Programming Innovation award nominee
May 2009
Number 7


Prize: One book of choice by Packt
SVG is standard format for representing vectorial graphics.

SVG graphics can be rendered in Web browsers but not all of them provide SVG support.

This class provides an alternative solution to render SVG graphics in any browser by converting it into an image in PNG format.

Manuel Lemos
Picture of Uku-Kaarel Jo~esaar
Name: Uku-Kaarel Jo~esaar <contact>
Classes: 8 packages by
Country: Estonia Estonia
Innovation award
Innovation award
Nominee: 5x

Recommendations

What is the best PHP SVG to PNG conversion class?
Parse SVG files and modifying nodes appropriately to convert

Example

<?php
#! /usr/bin/php

include_once './class.svg2png.php';


$fsvg = './gion_desktop.svg';
//$fsvg = $_GET['fsvg'];
//$fsvg = $argv[1];

$osvg = new
 
icfSVG ( $fsvg );

$osvg_ogd = $osvg->image();



//header( 'Content-type: image/jpeg');
//imagejpeg( $osvg_ogd ,'' ,90 );

//header( 'Content-type: image/gif');
//imagegif( $osvg_ogd );

header( 'Content-type: image/png');
imagepng( $osvg_ogd );

die(
'');



?>


  Files folder image Files  
File Role Description
Plain text file class.svg2png.php Class class file
Accessible without login Plain text file function.imagecreatefromsvg.php Aux. imagecreatefrom... function
Plain text file gion_desktop.svg Data for testing
Plain text file test.php Example test

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,378
This week:0
All time:1,639
This week:524Up
User Ratings User Comments (1)
 All time
Utility:31%StarStar
Consistency:43%StarStarStar
Documentation:-
Examples:62%StarStarStarStar
Tests:-
Videos:-
Overall:26%StarStar
Rank:4398