[Script] Delete Transparent Frames

Hi! I was trying to reimport a sprite sheet made in aseprite, which was exported with a .json for the animation tagging and easy game engine import.

My goal was learn how to make this export, so I was looking for how the file was in aseprite, to see the animation frames and its tags.

I found the jest_import_existing_tags.lua script that works for import the animation tags by .json file.
Install it and don’t run it yet.

  1. First import the sprite sheet with “File - Import - Import Sprite Sheets”
    Then choose your image, slice (I used “by rows”, but it depends how all animations were rendered in one sprite sheet - and try divide the image width by the number of columns to get the cell width; divide the image height by the number of rows to get the cell height).

  2. Install and run this lua script: (don’t forget to reopen aseprite or rescan scripts folder after install it)

local sprite = app.activeSprite
if not sprite then
  app.alert("No active sprite")
  return
end

local function isFrameEmpty(frameNumber)
  for _, cel in ipairs(sprite.cels) do
    if cel.frameNumber == frameNumber then
      if not cel.image:isEmpty() then
        return false
      end
    end
  end
  return true
end

app.transaction(function()
  for i = #sprite.frames, 1, -1 do
    if isFrameEmpty(i) then
      sprite:deleteFrame(i)
    end
  end
end)

app.refresh()
  1. The empty frames will be deleted.
  2. Use the jest_import_existing_tags.lua with all the frames successfully opened and choose the .json file from the sprite sheet export, and voila! Your animations will be tagged as before!

Script 100% made by ChatGPT. Not give me credits, just posted here bc if I got it, somebody may want this too.