PHP Classes

SVG to php array

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  SVG to php array  
Subject:SVG to php array
Summary:revise svg colors and export to jpg
Messages:2
Author:Greg Morris
Date:2011-08-28 19:22:27
Update:2011-09-24 02:27:30
 

  1. SVG to php array   Reply   Report abuse  
Picture of Greg Morris Greg Morris - 2011-08-28 22:31:10
Hi,

I'm looking for a class that can convert svg files into php (arrays?) for manipulation.

e.g. SVG:

<?xml version="1.0" standalone="yes"?>
<svg width="287" height="190">
<path style="fill:#800000; stroke:none;" d="M0 0L0 190L287 190L287 0L0 0z"/>
<path style="fill:#20c040; stroke:none;" d="M38 38L38 163L252 163L252 38L38 38z"/>
<path style="fill:#ffffff; stroke:none;" d="M43 43L43 158L247 158L247 43L43 43z"/>
<path style="fill:#a040c0; stroke:none;" d="M135 68.4244C116.63 70.8375 98.0371 72.3079 82 82.6991C73.844 87.9838 66.6953 96.6935 69.8002 107C72.8951 117.274 83.7502 123.153 93 126.988C115.783 136.436 142.796 137.648 167 134.715C182.714 132.81 200.217 129.288 212.996 119.319C221.169 112.944 225.995 102.741 220.467 93C215.979 85.0918 207.128 80.3821 199 77.0116C180.175 69.2055 155.249 65.7644 135 68.4244z"/>
<path style="fill:#000000; stroke:none;" d="M134 73.4244C117.551 75.5905 100.485 77.0594 86 86.0656C79.2727 90.2483 71.95 97.2886 74.8549 106C77.9573 115.303 88.5856 119.932 97 123.189C118.772 131.617 144.073 132.568 167 129.715C181.22 127.946 197.155 124.798 208.996 116.211C215.829 111.257 220.498 103.029 215.772 95.0039C211.665 88.0305 203.237 84.0706 196 81.2037C177.511 73.8791 153.766 70.8214 134 73.4244z"/>
</svg>


I want to manipulate the "fill" and "stroke" patch colors of the svg then save it as a jpg with the new values. Basically I would use a "color map" of sorts to revise to my colors e.g. "fill:#a040c0; stroke:none;" would always become "fill:#00009C; stroke-width:1; stroke:#7B3F00;" (notice I added the stroke width to the new variable) and the script would go through the svg file looking for all matching values. Each unique fill/stroke in the svg file will have its own "match" in the "color map".

Thanks!

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.