Batch optimizing images for web and games on Windows

Batch optimizing images for web and games on Windows

First you need to add the TexturePacker's bin directory to your path. Here you find 2 versions of TexturePacker: TexturePacker which is the command line version and TexturePackerGUI which is the "old" graphical user interface.

Updating all your sprite sheets at once

With this simple batch file you can update all sprite sheets from the settings in the *.tps files in one folder:

@echo off
for %%X in (*.tps) do (C:\Programme\TexturePacker\bin\TexturePacker.exe  %%X)

Using parameters from a .tps file

If you have many sprite sheets with almost identical parameters it's a tedious job to create .tps files for all of them.

Setting the parameters from command line might also result in long TexturePacker calls.

This is why we've added a combination of both: Using a .tps file as configuration with overrides from the command line:

You simply create a .tps file with all the settings but don't set the sprites or output files.

Now you can run commands similar to this:

TexturePacker settings.tps --data out.plist --sheet out.png spritesfolder

Updating .tps files from command line

You've got a bunch of .tps files and want to update them without opening each file? E.g. this command sets the trim margin and saves a new .tps file:

TexturePacker ~/Desktop/sheet.tps --trim-margin 10 --save ~/Desktop/sheet.tps

You can of course combine this with a loop to update all sheets in your folder:

@echo off
for %%X in (*.tps) do (C:\Programme\TexturePacker\bin\TexturePacker.exe  %%X --trim-margin 10 --save %%X)

Mass conversion of files

Write a simple batch file containing these lines to do as mass conversion of images:

@echo off
for %%X in (*.png) do (C:\Programme\TexturePacker\bin\TexturePacker.exe  <parameters>  %%X)

Please replace <parameters> with your parameters needed.