This is basically a js library that solves this problem: http://gis.stackexchange.com/questions/126380/library-for-minimum-bounding-box-by-width-in-javascript-or-python