I recently played something around with libgdx. And at some point you need to create a spritesheet (or texturemap), where you need many small images converted into one big image. As it turns out, imagemagick saves the day with a simple and quick solution for this job.
montage INPUT.PNG -background none -tile x2 -geometry 128x128+0+0 OUTPUT.PNG
It’s simple as it looks. INPUT.PNG are the names of your input files (for example “myfiles/*.png”). The -tile option control the rows of your new image this means in our case we get an image with two rows. -geometry takes the size of your images. And the name of your output file.
So for example two spritesheets, one with the one row option and one with the two row option:
#!/bin/bash TEXTURE=128x128 #cleanup sheet.png and sheet folder if [ -e "sheet.png" ];then rm sheet.png fi rm sheet/* #create new sheet.png cd original for f in *.png do #create a left & right version of my images convert "$f" -flop "../sheet/right_$f" cp "$f" "../sheet/left_$f" done cd .. montage sheet/*.png -background none -tile x2 -geometry "$TEXTURE"+0+0 sheet.png #resize sheet convert sheet.png -resize 512x128 sheet_rect.png