This is a thing I made in Nim a little while back. It's intended for making custom sprite packing scripts. I gave it a quick cleanup and readme document and threw it on GitHub. I might go back later to see if I can make it a little more accessible.
https://github.com/triplefox/three-packer