Export tileset as GIF

I used the tilemap feature to design a tileset, and wanted each 16px frame to be exported individually as a frame in a GIF. This would mean that if I had 20 tiles, I’d export a 20-frame GIF. Is there a way to do this automatically within Aseprite itself, or would I need to manually copy and paste the tiles to separate frames?

Hi @bluedragon8633,

You could adapt the Lua script from this thread

to suit your purposes. The Aseprite scripting API is here.

Here is a rough draft to illustrate the concept:

local srcSprite = app.activeSprite
if srcSprite then
    local srcLayer = app.activeLayer
    if srcLayer then
        local isTileMap = srcLayer.isTilemap
        if isTileMap then
            local tileSet = srcLayer.tileset

            local tileCount = #tileSet
            local grid = tileSet.grid

            local tileDim = grid.tileSize
            local tileWidth = tileDim.width
            local tileHeight = tileDim.height

            local trgSprite = Sprite(tileWidth, tileHeight)
            local trgLayer = trgSprite.layers[1]

            -- Where first tile of tilemap is empty,
            -- first frame would also be empty.
            local trgFirstFrame = trgSprite.frames[1]
            local trgFirstImage = Image(tileWidth, tileHeight)
            trgFirstImage:drawImage(tileSet:getTile(0))
            trgSprite:newCel(
                trgLayer,
                trgFirstFrame,
                trgFirstImage,
                Point(0, 0))

            for i = 1, tileCount - 1, 1 do
                local trgFrame = trgSprite:newFrame()
                local srcTile = tileSet:getTile(i)
                local trgImage = Image(tileWidth, tileHeight)
                trgImage:drawImage(srcTile)
                local trgCel = trgSprite:newCel(
                    trgLayer,
                    trgFrame,
                    trgImage,
                    Point(0, 0))
            end

            app.refresh()
        end
    end
end

(The script above creates a new sprite, it doesn’t save as a .gif.)

Best,
Jeremy