Skip to content

Instantly share code, notes, and snippets.

@matejd
Created February 20, 2015 11:07
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 matejd/92a55cb6daf00cd0d0eb to your computer and use it in GitHub Desktop.
Save matejd/92a55cb6daf00cd0d0eb to your computer and use it in GitHub Desktop.
<?php
//ini_set('display_errors', 1);
//error_reporting(E_ALL);
$svg = '<?xml version="1.0"?>
<svg width="120" height="120" viewBox="0 0 120 120"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<!-- Materialisation of anchors -->
<path d="M60,15 L60,110 M30,40 L90,40 M30,75 L90,75 M30,110 L90,110" stroke="grey" />
<!-- Anchors in action -->
<text text-anchor="start"
x="60" y="40">A</text>
<text text-anchor="middle"
x="60" y="75">A</text>
<text text-anchor="end"
x="60" y="110">A</text>
<!-- Materialisation of anchors -->
<circle cx="60" cy="40" r="3" fill="red" />
<circle cx="60" cy="75" r="3" fill="red" />
<circle cx="60" cy="110" r="3" fill="red" />
<style><![CDATA[
text{
font: bold 36px Verdana, Helvetica, Arial, sans-serif;
}
]]></style>
</svg>
';
$image = new Imagick();
$image->setResolution(800, 800);
$image->readImageBlob($svg);
$image->setImageFormat("png32");
$image->scaleImage(400, 400);
$image = $image->flattenImages();
header("Content-type: image/png");
echo($image);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment