This software lets you import a game screenshot.
Then it extracts the tileset, and exports it along with the map, and some stats about witch tile goes next to which one.
The screenshot does not need to be cropped at the corner of a tile, the software tries different combinations and picks the one that leads to the best result.

The source also has a function to generate maps based on the statistics, but it's so badly optimized that the percentage on the progress bar for a typical map is often so low that it's not even holdable by a floating point variable.

tileUser.7z