Crop sprites for minimal spritesheet size
Posted: 2018-01-16T13:40:59-07:00
Hi all!
I have some sprites, for example 128x128 (or 256x256) pixels.
If I have 8 sprites, I can make this spritesheet with only one command:
As you can see, here is too much borders with alpha = 100%.
Is it possible to make the mask and crop all alpha borders from this sprites?
If I put all sprites together,
then it looks like (added white):
In this case I get image 207x97 (complete without alpha borders) and here was top left pixel {49, 61}. (added white)
Then cut all sprites with this musk. Save it, then montage with the command above.
And result looks like:
With white background:
For this 8 images I need about 15 minutes. But I have every spritesheet with 128 or 256 sprites and I want make it automatically.
Version: ImageMagick-7.0.5-4-portable-Q16-x64
I have some sprites, for example 128x128 (or 256x256) pixels.
If I have 8 sprites, I can make this spritesheet with only one command:
Code: Select all
montage "Input_Folder/*.png" -geometry +0+0 -tile 8x -background rgba(0,0,0,0) -quality 100% Output_Folder\spritesheet_8x_128.png
As you can see, here is too much borders with alpha = 100%.
Is it possible to make the mask and crop all alpha borders from this sprites?
If I put all sprites together,
Code: Select all
convert "Input/*.png" -background none -flatten musk.png
In this case I get image 207x97 (complete without alpha borders) and here was top left pixel {49, 61}. (added white)
Code: Select all
convert musk.png -trim musk_trim.png
Then cut all sprites with this musk. Save it, then montage with the command above.
And result looks like:
With white background:
For this 8 images I need about 15 minutes. But I have every spritesheet with 128 or 256 sprites and I want make it automatically.
Version: ImageMagick-7.0.5-4-portable-Q16-x64