Is there a way to open a 'new reference layer from file' via script?

Hi, I’m new to Lua and to the Aseprite API, but I’m reading the API docs and I haven’t found a way to open a ‘reference layer’ via script. What I want is to open all the pngs from a folder as ‘reference layers’ in Aseprite. Is that possible?

Hi @phartz,

Welcome aboard. I suspect it’ll take some hacky workarounds to pull of your idea. Here’s an experiment I tried. Maybe it will give a starting point:

app.command.NewLayer {
    name = "MyReference",
    reference = true,
    top = true }

local sprite = app.activeSprite
local layer = app.activeLayer
local frame = app.activeFrame
local image = Image { fromFile= "myFilePath.ext" }
local position = Point(0, 0)
local cel = sprite:newCel(layer, frame, image, position)


My primary source was app.command.NewLayer.

Depending on how reliable you need the script to be, you may want to search for any Github issues on reference layer behavior. For example, this one… Though, could be that you’re already aware and that’s why you’re asking.

Good luck!


Thanks, man. I’ll try this.