GDXTexturePacker

Standalone version of libGDX's TexturePacker with a GUI

APACHE-2.0 License

Stars
4

GDXTexturePacker

A standalone version of libGDX's TexturePacker with a GUI

LibGDX provides a very full-featured way to pack many images into one texture with its TexturePacker tool. Unfortunately for some developers, it isn't the easiest tool to use. There's a commercial packer with a GUI and an older wrapper around libGDX's TexturePacker, but nothing recent that packs textures for libGDX has had both a GUI and a $0 price tag. This is an attempt to change that, using libGDX's code as a base.

Usage

There are several downloads on the Releases tab of this project; you probably want the .jar download unless you don't have Java installed. Running the jar or other executable presents you with a simple GUI: select the input folder that contains the images to pack, select the output folder (preferably an empty one, to avoid potentially overwriting something), and prefix for the atlas and texture pages (the default, "pack", will result in "pack.atlas" and "pack.png" as the first files it generates; entering "monsters" will make "monsters.atlas" and "monsters.png"). You can optionally include a file with the name "pack.json" in each folder with additional configuration. The format for pack.json files is a simplified version of JSON (so it can be edited with any text editor), and is described here. Once you've entered at least the top two fields, click the bottom "Pack Textures!" button and wait for it to complete, which may take a while on larger sets of images. The blue "Processing..." message to the right should change to a green "SUCCESS!" once things are done, or possibly a red "PROCESSING FAILURE..." if something went wrong. It could also crash if there are far too many images for your computer to handle, which also can occur with libGDX's command-line TexturePacker. Check the output directory you specified and see how well your images compressed!

Troubleshooting

If you are packing a large number of images, you may want to include a pack.json file with at least the option fast: true set and possibly the stripWhitespaceX and stripWhitespaceY options set to true as well, though the last two require additional code to work properly. Exceptionally large amounts of images may use all the memory the JVM has available to it, which has a default that is rather tiny. The platform-specific binaries (not the .jar) on the Releases tab default to 1 gigabyte of RAM used for this program, which should be enough for at least 50 1024x1024 pages of textures. You can edit the config.json file included with the platform-specific binaries (it's inside the .app version for Mac OS X, you need to open it as a folder and find it at GDXTexturePacker.app\Contents\MacOS\config.json) to change the default memory maximum if you need more. The line that determines this in config.json looks like "-Xmx1G" , all you need to do to increase the limit is change it to "-Xmx2G" for 2 gigabytes, "-Xmx3G" for 3 gigabytes, and if you somehow need more, remember that you can have multiple atlases if you have truly massive quantities of images (or very large images). You can also reduce the limit if memory is at a premium on the computer running the packer; the default on the .jar is whatever the default is for Java on your computer, which is usually 256 megabytes, and config.json can reduce the maximum memory it uses as well ("-Xmx512M" for 512 megabytes, "-Xmx256M" for 256 megabytes, "-Xmx128M" for 128 megabytes, and I wouldn't recommend going lower than that). Save config.json and run again to see if the failure message goes away.

Credits

Almost all the work that went into this was done already by LibGDX developers, particularly @NathanSweet, who wrote much of the TexturePacker code this uses. I, Tommy Ettinger, am very grateful to the large and friendly LibGDX community as well.