Auto Sprite Offsets Script with NodeJS

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!
User avatar
Posts: 39
Joined: Thu Apr 13, 2017 12:28 pm

Auto Sprite Offsets Script with NodeJS

Post by Lycanite »

I created a quick NodeJS script that does sprite offsets for pngs with support for auto offsets based on what Slade does, figured I'd just share it here in case anyone has use for it or just wants to look. It uses the png-chunks-extract and png-chunks-encode libraries for node and is great for automation. You can find it here: ... ts/2439692

While Slade is great and all, when managing a lot of sprites for my project I found that I had to keep loading up Slade, opening the folder where my sprites are and then selecting them and setting their offsets. Slade can do this for a full selection of sprites and then auto set them to monster, projectile, etc but then if you edit things outside of Slade you have to reopen the directory every time, etc. I also prefer just running a quick command from the terminal (linux).

So I wanted to automate things where I can run a quick command in the terminal to bulk auto offset all pngs in the folder I am in. (In KDE linux I can simply go to the folder, hit F4 and pop the command in and done, much faster).
I looked at grabpng and setpng first but setpng seems to be extinct for linux and grabpng uses some ancient library making it unusable on linux to, and neither of them seem to do auto offsets.

The script can be easily improved to handle entire folders asynchronously (I just use a bash script to iterate files for now) and can be extended with other auto offsets like for weapons or based on matching sprite name patterns, etc too. Should work fine for node on mac and windows as well.

Return to “Resources”