Page 1 of 1

Several images to spritesheet

Posted: Mon Jun 06, 2022 7:07 am
by GVovkiv
Is there any good tools/plugins/program, etc to produce spritesheet from several image files?
I am on linux, so suggestions for windows (via wine) works, too.
Especially i'm interested in something that can be easly automated (so, for example, i can write script to create spritesheet for specific directory when i run it).
Any suggestions?

Re: Several images to spritesheet

Posted: Mon Jun 06, 2022 7:55 am
by marclurr
You can do it with Aseprite (at least on windows). If all the frames of your animation are named following some convention like idle_1.png, idle_2.png, run_1.png, run_2.png when you open one of the files it will ask you if you want to import the other files as animation frames. You can then just export the project as a spritesheet as normal. I'm not sure if it's easily scriptable though, I suspect not.

You can also easily write something yourself with Love2D, simply load each file, create a FrameBuffer that is the right size (for a single row horizontal sheet the width of a frame multiplied by the number of frames by the height of a frame), render them in order side by side then you can get the image data from the FrameBuffer and save that using https://www.love2d.org/wiki/ImageData:encode

Edit: I meant to say Canvas. FrameBuffer is gone.

Re: Several images to spritesheet

Posted: Mon Jun 06, 2022 7:58 am
by MrFariator
I personally use TexturePacker, which has a GUI as well as command line tools for automation purposes, basically creating the spritesheet file, as well as an accompanying file specifying the quads there-in. It doesn't come with a löve2d exporter right out of the box, but it's relatively easy to write one to your specifications.

For a free alternative, there's ImageMagick. Additionally, if you take a gander at the awesome-love2d page, there's a couple texture atlas packers listed (under "Drawing").

Re: Several images to spritesheet

Posted: Mon Jun 06, 2022 7:04 pm
by darkfrei
I have the script for ImageMagick:

best_spritesheet_8x8.bat (it packs to spritesheet 8x8, multiple files if more than 64 sprites)

Code: Select all

magick "input/*.png" -background none ^
   ( -clone 0--1 -layers merge ^
   -set option:cropper "%%[@]" +delete ) ^
   -crop %%[cropper] +repage ^
   MIFF:- | magick montage MIFF:- -background none ^
   -tile 8x8 -geometry +0+0 best_spritesheet_8x8.png
pause
It crops the unneeded alpha too.