Dimitri,
Welcome to CodeRanch!
Does
Snap.svg do what you want? It looks like the most comprehensive library for dealing with svg images in JavaScript. If it doesn't do what you want, I don't think anything does. The library is fairly young though so even if it doesn't do what you want now, it might in 3 months.