Take a look at this: https://github.com/juj/RectangleBinPack and maybe add the Guillotine algorithm to Atlasmaker.