there is also a ruby called Simplify contours available here

simplify contours

I have found it very useful.