The only thing I can think of is that not all the images have the correct dimension or size. You must divide the entire image by power of 2. If each image is 128x128 then the entire image needs to be 512x512. If each image is 256x256 then the entire image needs to be 1024x1024.
I am also looking for a fast way to do this myself because I don't want to try to fit a ton of images into one image.
I am also looking for a fast way to do this myself because I don't want to try to fit a ton of images into one image.