This blog is no longer updated. Feel free to copy any useful information to other blogs or wikis as this site may not exist for much longer. Thanks.


sspack your images

February 27th, 2010 | 3 comments

Today I checked in the first update to Sprite Sheet Packer in a few months. Inspired by a discussion post I somehow didn’t see for a few months and my own realization of the usefulness, I extracted the build process of the tool into a command line application and made the UI tool simply a wrapper around it. This enables many more scenarios for integration.

First let’s do the techie thing and just look at the arguments of the tool:

C:\Users\Nick\Desktop>sspack
Missing required argument '/image'.
Missing required argument '/map'.
/image:<string>  Output file name for the image.
/map:<string>    Output file name for the map.
/mw:<int>        Maximum ouput width. Default:'4096'
/mh:<int>        Maximum ouput height. Default:'4096'
/pad:<int>       Padding between images. Default:'1'
/pow2            Ensures output dimensions are powers of two.
/sqr             Ensures output is square.
/r               Searches subdirectories of any input directories.
/il:<string>     Path(s) to file(s) listing the images to build.
<input>          Images to pack.

Those first two lines are unfortunately a bit misleading but the library I used for parsing command line arguments didn’t have complex logic. You technically are required to have image and map but you also must have something for either il or the input images. Most of the arguments make sense but the last few may trip people up. First the /r. If you have that flag, your searches for input will be recursive. So you could invoke this:

sspack /image:test.png /map:test.txt C:\Users\Nick\Desktop\MyImages\*.png

And it would find all PNG images in the MyImages folder. Note that the wildcard is really primitive and likely to break if you try to do anything with it in the middle of the word; it’s mainly there for finding a bunch of images in one folder. Anyway, if you were to add in the /r flag, it would find any PNG image in the MyImages folder and any subdirectories. That’s it.

Next the il flag. Since you may want to pack lots and lots of images (like the tool requires), you can make a file like this:

C:\Users\Nick\Desktop\MyImages\1.png
C:\Users\Nick\Desktop\MyImages\2.png
C:\Users\Nick\Desktop\MyImages\3.png
C:\Users\Nick\Desktop\MyImages\4.png

And invoke sspack with that file which it uses to find the files:

sspack /image:test.png /map:test.txt C:\Users\Nick\Desktop\ImagesToPack.txt

This is really nice because you could make any other tool to generate that file and kick off the build. This is actually all that the UI tool does. It simply builds up that list (which it saves in %AppData%\Sprite Sheet Packer) and uses all the UI to simply build up the command to launch a Process to run sspack. Now you can make your own UI tool or integrate sprite sheet packing into your build.

If you have any suggestions, feel free to let me know, but no promises. As you can see, I don’t really do rapid development on this project. Also feel free to submit patches on CodePlex if you have fixes for bugs or enhancements. That really helps since I can do a quick code review and put it up for everyone else to use.


Possibly Related Posts

(Automatically Generated)
Sprite Sheet Packer Tool
Sprite Sheet Packer Tool – XNA GS Example
Creating Your Own XNB Files
Visual Studio 2010, XNA, and you
Quick and Dirty Screenshots in PC Games

  1. March 21st, 2010 at 09:47
    Quote | #1

    Great work Nick. Speaking of not seeing discussion posts on the codeplex site, I left one there for you a couple of weeks ago :)

    I only just read your last paragraph in this post – I’ll try to put my suggestions into a patch.
    - Aranda

  2. jmdesp
    April 25th, 2010 at 06:11
    Quote | #2

    Hi, in version 2.3, the wildcart option really seems to be broken. Even a case as simple as sspack.exe *.png fails …

    Ok, so I just so you removed support for wild carts. /r also is removed ?

  3. jmdesp
    April 25th, 2010 at 06:13
    Quote | #3

    And I forgot, could you give just a little bit more info about MEF extensibility ?
    I would love to have support for gif format.

Comments are closed.