Anuken/Mindustry · error · IllegalArgumentException

Max image size exceeded

Error message

Max image size exceeded

What it means

While packing generated data images into the atlas, DataManager installs a MultiPacker.add override that rejects any region whose pixmap width exceeds 2000 pixels. Oversized textures are refused to keep atlas pages within safe GPU limits.

Solutions

  1. Resize the offending image so its width is at most 2000px.
  2. Split a large sheet into several smaller textures.
  3. Identify the culprit from the packing log / currentHash path.

Example fix

// before: sprite.png is 4096x4096 -> 'Max image size exceeded'
// after: downscale to <=2000px width (e.g. 1024x1024) and re-export
Defensive patterns

Strategy: validation

Validate before calling

// Reject oversized textures before packing.
if(region.pixmap.width > 2000) {
    throw new IllegalArgumentException("Texture too wide (" + region.pixmap.width + " > 2000): " + name);
}

Type guard

boolean withinAtlasLimit(PixmapRegion r){ return r != null && r.pixmap.width <= 2000; }

Prevention

When it happens

Trigger: A data image (sprite) contributed to the packer is wider than 2000px during the data-image packing pass.

Common situations: Mod or generated asset includes an oversized sprite sheet; full-resolution artwork not downscaled; accidentally bundling a UI screenshot as a sprite.

Related errors


AI-assisted analysis of Anuken/Mindustry@f695ad7e60 (2026-08-14). Data as JSON: /api/errors/33c87bbccca68ca3. Report an issue: GitHub.

Appendix: source

Thrown at core/src/mindustry/mod/DataManager.java:87

        //remove content that doesn't need to be packed
        contentToPack.removeAll(u -> imagesWithHashes.contains(hashes.get(u)));

        ObjectMap<String, ImageAsset> imageMap = new ObjectMap<>();
        for(var image : images){
            imageMap.put(DataImagePacker.regionPrefix + image.name, image);
        }
        int[] packed = {0};
        ObjectMap<String, PixmapRegion> imagePixmaps = new ObjectMap<>();
        PixmapRegion error = new PixmapRegion(Pixmaps.blankPixmap());
        UnlockableContent[] currentContent = {null};
        String[] currentHash = {null};

        MultiPacker saver = new MultiPacker(false){
            @Override
            public void add(PageType type, String name, PixmapRegion region, int[] splits, int[] pads){
                try{
                    if(region.pixmap.width > 2000) throw new IllegalArgumentException("Max image size exceeded");

                    //strip duplicate prefix
                    if(name.startsWith(DataImagePacker.regionPrefix)) name = name.substring(DataImagePacker.regionPrefix.length());
                    String path = "generated/" + currentHash[0] + "/" + name + ".png";
                    ImageAsset newImage = new ImageAsset();
                    newImage.setPath(path);
                    //it would be nice to do this async, but the pixmap typically gets disposed right after add() exist
                    byte[] bytes = PixmapIO.writePngBytes(region.pixmap);
                    newImage.updateData(bytes);

                    images.add(newImage);
                    packed[0] ++;
                }catch(Exception e){
                    Log.err("Failed to pack image " + name, e);
                }
            }

            @Override

View on GitHub (pinned to f695ad7e60)