SVG to picture converter in PHP http://labs.shikiryu.com/svgtoimage/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?
  2. include 'svgtoimage.php';
  3. /*
  4. <image x="184" y="286" width="10" height="10" preserveAspectRatio="none" href="imageurl4.png" style="cursor: pointer; opacity: 1; display: none; " opacity="1"></image>
  5. <image x="204" y="286" width="10" height="10" preserveAspectRatio="none" href="imageurl5.png" style="cursor: pointer; opacity: 1; display: none; " opacity="1"></image>
  6. <path d="M153 334
  7. C153 334 151 334 151 334
  8. C151 339 153 344 156 344
  9. C164 344 171 339 171 334
  10. C171 322 164 314 156 314
  11. C142 314 131 322 131 334
  12. C131 350 142 364 156 364
  13. C175 364 191 350 191 334
  14. C191 311 175 294 156 294
  15. C131 294 111 311 111 334
  16. C111 361 131 384 156 384
  17. C186 384 211 361 211 334
  18. C211 300 186 274 156 274"
  19. style="fill:white;stroke:red;stroke-width:2"/>
  20. */
  21. $svg = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="512">
  22. <desc>Created with Raphael</desc>
  23. <defs></defs>
  24. <image x="0" y="0" width="300" height="512" preserveAspectRatio="none" href="http://labs.shikiryu.com/experimental-cut/images/pieces/fond.jpg"></image>
  25. <rect x="168" y="275" width="52" height="70" r="0" rx="0" ry="0" fill="none" stroke="#FFF" stroke-width="3" stroke-dasharray="8,3" transform="rotate(21.91207728 194 310)" style="opacity: 1;" opacity="1"></rect>
  26. <circle cx="50" cy="50" r="50" fill="turquoise" stroke="#000"></circle>
  27. <circle cx="100" cy="50" r="40" stroke="#000" stroke-width="2" fill="none"/>
  28. <image x="170" y="277" width="48" height="66" preserveAspectRatio="none" href="http://labs.shikiryu.com/experimental-cut/images/pieces/1.png" style="cursor: move; opacity: 1; " r="90" opacity="1" transform="rotate(21.91207728 194 310)"></image>
  29. <path d="M50 50 V150 H150 L200 50 Z" stroke="red" stroke-width="3" stroke-dasharray="2,2" />
  30. <polygon points="60,150 160,60 260,150 210,250 110,250" stroke="red" stroke-width="3"/>
  31. <polyline stroke="gray" stroke-width="5"
  32. points="80,250 80,280 60,280 60,310 80,310 80,340 40,340 40,370 80,370 80,400 20,400 20,430 80,430" />
  33. </svg>';
  34. //$svgtoimage = SVGTOIMAGE::parse($svg);
  35. //$svgtoimage = new SVGTOIMAGE($svg);
  36. //$svgtoimage = SVGTOIMAGE::load('france.svg');
  37. $svgtoimage = SVGTOIMAGE::load('Exemple_histogramme.svg');
  38. //$svgtoimage = SVGTOIMAGE::load('basic.svg');
  39. $svgtoimage->setShowDesc();
  40. //$svgtoimage->setWidth(300);
  41. //$svgtoimage->setHeight(512);
  42. //header('Content-type: image/png');
  43. echo $svgtoimage->toImage();