Skip to content

Instantly share code, notes, and snippets.

@Fil
Created January 25, 2013 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fil/4636174 to your computer and use it in GitHub Desktop.
Save Fil/4636174 to your computer and use it in GitHub Desktop.
<?php
## Service Web de conversion d'un SVG (passéen URL) en png
## ?url=http://......./svg2png.php?url=(adresse du svg)
## renvoie le png converti
## TODO : gestion d'entete en cas d'erreur quelconque
## utilise : SPIP
## utilise : rsvg ou ImageMagick http://seenthis.net/messages/86415
include 'ecrire/inc_version.php';
include_spip('inc/distant');
include_spip('base/abstract_sql');
if ($u = _request('url')
AND preg_match(',^https?://.*svg$,i', $u)
AND $l = copie_locale($u)) {
# rsvg
`rsvg-convert $l -o $l.png`;
# convert ?
# `convert $l $l.png`;
header('Content-Type: image/png');
readfile("$l.png");
@unlink($l);
@unlink("$l.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment