javalibgdx

Libgdx packer fails with java.lang.RuntimeException: Image does not fit with max page width 1024 and paddingX 2: 003[0,0 1030x154]


I'm sarting the packing process with the below details:

java -cp gdx-texturepacker.jar  com.badlogic.gdx.tools.imagepacker.TexturePacker2 D:\tem D:\tem spritesheet.tmp
Exception in thread "main" java.lang.RuntimeException: Error packing files.
        at com.badlogic.gdx.tools.imagepacker.TexturePacker2.process(TexturePacker2.java:361)
        at com.badlogic.gdx.tools.imagepacker.TexturePacker2.main(TexturePacker2.java:394)
Caused by: java.lang.Exception: Error processing directory: D:\tem
        at com.badlogic.gdx.tools.FileProcessor.process(FileProcessor.java:117)
        at com.badlogic.gdx.tools.imagepacker.TexturePackerFileProcessor.process(TexturePackerFileProcessor.java:60)
        at com.badlogic.gdx.tools.FileProcessor.process(FileProcessor.java:89)
        at com.badlogic.gdx.tools.imagepacker.TexturePackerFileProcessor.process(TexturePackerFileProcessor.java:39)
        at com.badlogic.gdx.tools.imagepacker.TexturePacker2.process(TexturePacker2.java:359)
        ... 1 more
Caused by: java.lang.RuntimeException: Image does not fit with max page width 1024 and paddingX 2: 003[0,0 1030x154]
        at com.badlogic.gdx.tools.imagepacker.MaxRectsPacker.packPage(MaxRectsPacker.java:78)
        at com.badlogic.gdx.tools.imagepacker.MaxRectsPacker.pack(MaxRectsPacker.java:56)
        at com.badlogic.gdx.tools.imagepacker.TexturePacker2.pack(TexturePacker2.java:54)
        at com.badlogic.gdx.tools.imagepacker.TexturePackerFileProcessor.processDir(TexturePackerFileProcessor.java:87)
        at com.badlogic.gdx.tools.FileProcessor.process(FileProcessor.java:115)
        ... 5 more

What is wrong with the input files, if they are

enter image description here

enter image description here

enter image description here


Solution

  • The default pack configuration for the texture-packer has a maxWidth and maxHeight of 1024 pixels, since one of your images is wider than that it cannot fit into the packed texture atlas.

    You can override the default configuration by using a configuration file, the GDX texture packer documentation outlines how, but one simple way is to just place a file called pack.json in your input folder (in your case D:\tem).

    If you increase the maxWidth to, for example, 2048 it should work, to do that your pack.json could look something like this:

    {
      "maxWidth": 2048,
      "maxHeight": 2048
    }