Fix internal pattern shrink/expand and make it available in API

As the topic says, would be nice if those functionality was fixed so it produces results just like dblue’s resizer tool - but a lot faster. Also then, make it available in the API, so shinking / expanding becomes faster and easy there, too.