I need a function that will outline a bitmap and create a SVG offset path around it. White fill around the image should count the same as transparent and should be outlined as well (see attached image for more details).
function should look like this:
function(svg, offset, smoothing) { return offset_path; }
svg: Input SVG code
offset: offset distance in px from outer border of SVG
smoothing: some kind of variable that will define how much the script should smoothen out the offset path (simplify and remove points, we cant have a offset with too many points in the path)
offset_path: the returned offset path svg code
Prefered is that we do this in JavaScript but I'm open for all suggestions on how to solve this.