Several images to spritesheet

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
GVovkiv
Party member
Posts: 686
Joined: Fri Jan 15, 2021 7:29 am

Several images to spritesheet

Post 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?
User avatar
marclurr
Party member
Posts: 158
Joined: Fri Apr 22, 2022 9:25 am

Re: Several images to spritesheet

Post 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.
Last edited by marclurr on Mon Jun 06, 2022 8:06 am, edited 1 time in total.
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Several images to spritesheet

Post 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").
User avatar
darkfrei
Party member
Posts: 1204
Joined: Sat Feb 08, 2020 11:09 pm

Re: Several images to spritesheet

Post 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.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 7 guests