Created
December 17, 2011 19:11
-
-
Save mgdm/1491089 to your computer and use it in GitHub Desktop.
RSVG with scaling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$width = $height = 1000; | |
if (isset($_GET['width'])) { | |
$width = (int) $_GET['width']; | |
} | |
if (isset($_GET['height'])) { | |
$height = (int) $_GET['height']; | |
} | |
header("Content-Type: image/png"); | |
$r = Rsvg::createFromFile('karate.svg'); | |
$dimensions = $r->getDimensions(); | |
$s = new CairoImageSurface(CairoFormat::ARGB32, $width, $height); | |
$c = new CairoContext($s); | |
$c->scale($width / $dimensions['width'], $height / $dimensions['height']); | |
$r->render($c); | |
$s->writeToPng("php://output"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment