Texture Packer Command line multiple images

4.8k views Asked by At

I’m using TexturePacker from the command line and am unable to get it to pack multiple sprites into 1 sheet. It allows me to do 1 sprite so the command is fine.

This is the command I am using.

"TexturePacker --format sparrow --texture-format atf --opt DXT5 --max-width 2048 --max-height 2048 --size-constraints POT --pack-mode Best --enable-rotation --trim-mode Trim --algorithm MaxRects --multipack --border-padding 5 --shape-padding 5 --reduce-border-artifacts --scale " + sheetInfo.scale + " --data " + imageOutputDirectory + "\" + lanfPrefix + "\" + sheetInfo.name + ".xml " + "--sheet " + imageOutputDirectory + "\" + lanfPrefix + "\" + sheetInfo.name + ".atf image1.png image2.png";

Any ideas why this isn't working? According to the documentation, it should work.

2

There are 2 answers

0
Derek Lawrence On BEST ANSWER

I was unable to find any real way to fix this even contacted the developer of texture packer but got no response. Instead I was able to accomplish the desired outcome by copying all needed files to a temp directory and then add the directory to the end of the texturepacker call instead of individual images.

1
M_Tessmann On

Due to the poor TexturePacker documentation, it took me much trial and error to figure this out!

To add multiple images to a single sprite sheet, here is a sample command that will create an atlas called out.png (the default) containing images img_1 to img_4...

TexturePacker --format unity-texture2d img_1.png img_2.png img_3.png img_4.png

The key is the list of image filenames separated only by spaces. I am working from Python, so here is the script I use to create the same atlas that the sample line above will give you. Using glob with wildcards allows me to select images from a folder containing many images and eliminates the need to isolate the files I want into a folder just for TexturePacker's sake.

import subprocess, glob
TP = r"C:\Program Files\CodeAndWeb\TexturePacker\bin\TexturePacker.exe"
baseFrame = "img"
def FillAtlas(baseFrame):
    globString = baseFrame + "_*.png"
    frameList = glob.glob(globString)
    imgList = []
    for frame in frameList:
        imgList.append(frame)
    TPargs = [TP, "--format", "unity-texture2d"] + imgList
    subprocess.call(TPargs)

FillAtlas(baseFrame)