Skip to content

Instantly share code, notes, and snippets.

@Amzd
Last active August 23, 2025 12:42
Show Gist options
  • Select an option

  • Save Amzd/ad3ea2b08bd3f413b36c948c2e341ab2 to your computer and use it in GitHub Desktop.

Select an option

Save Amzd/ad3ea2b08bd3f413b36c948c2e341ab2 to your computer and use it in GitHub Desktop.
Aseprite/LibreSprite script to export each tag as a spritesheet. Shortcut for doing `File > Export > Export Sprite Sheet` for every tag.
local spr = app.sprite
if not spr then return print('No active sprite') end
local path, title = spr.filename:match("^(.+[/\\])(.-).([^.]*)$")
-- PREFERENCES
if not ExportScriptPreferences then
ExportScriptPreferences = {}
end
if not ExportScriptPreferences[spr.filename] then
ExportScriptPreferences[spr.filename] = {}
ExportScriptPreferences[spr.filename].exportPath = "{title}-{tag}.png"
end
-- EXPORT
function Export(exportPath, layer)
local p = app.fs.filePath(spr.filename)
for _, tag in ipairs(spr.tags) do
local subpath = exportPath:gsub('{tag}', tag.name):gsub('{title}', title)
app.command.ExportSpriteSheet {
ui = true,
askOverwrite=true,
type = SpriteSheetType.HORIZONTAL,
textureFilename = app.fs.joinPath(p, subpath),
-- dataFilename = tag .. '.json',
-- dataFormat = SpriteSheetDataFormat.JSON_ARRAY,
tag = tag.name,
layer = layer,
}
end
end
-- UI
local data = Dialog { title="Exporter" }
:entry { id="layer", label="Layer: ", text=app.layer.name }
:entry { id="exportPath", label="Filename: ", text=ExportScriptPreferences[spr.filename].exportPath }
:button { id="confirm", text="Save sheets" }
:button { id="cancel", text="Cancel" }
:show().data
if data.confirm then
ExportScriptPreferences[spr.filename].exportPath = data.exportPath
Export(data.exportPath, data.layer)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment