One click, quick black color outline

I recommend this extension: Magic Pencil for Aseprite by Kacper Woźniak. It offers more practical brushes and real-time outline preview, making it incredibly useful.

——————————
Kept what was written before as a memento, the simple script I once thought were useful during my newbie days.
——————————
outline script

Applicable Scenes:
The Style with the simple black outline.
Quickly check the picture’s outline with a dark color.

Lua content:

local sprite = app.activeSprite
local cel = app.activeCel

if not sprite or not cel then
    app.alert(‘Please select a layer and image first’)
    return
end

-- Get the current image
local image = cel.image
local width, height = image.width, image.height

-- Creates an image larger than the original image. Used to add an outline
local outlineImage = Image(width + 2, height + 2)

local outlineColor = Color{ r=0, g=0, b=0, a=255 } -- black stroke. rgb is the colour, a is the transparency

-- Add a stroke around the image.
for y = 0, height - 1 do
    for x = 0, width - 1 do
        if image:getPixel(x, y) ~= 0 then
            -- add outlines in all four directions
            outlineImage:putPixel(x + 1, y, outlineColorr) -- up
            outlineImage:putPixel(x + 1, y + 2, outlineColorr) -- down
            outlineImage:putPixel(x, y + 1, outlineColorr) -- left
            outlineImage:putPixel(x + 2, y + 1, outlineColorr) -- right
        end
    end
end

-- Draw the original image to the centre of the new image.
outlineImage:drawImage(image, 1, 1)

-- Apply the new image with the outline to the current layer
cel.image = outlineImage

-- move the coordinates of the new image up to the left, aligning the position of the original image
cel.position = Point(cel.position.x-1, cel.position.y-1)

-- Refresh the image
app.refresh()

Attention:
Use this script only when [colour mode] is [rgb colour].
You can bind a shortcut to execute the script (as the title says), I used“S” , which would be very handy. After making the outline, if you don’t want it, 2 times undo is enough.
The basic content of the script is provided by ChatGPT, I only slightly modified and commented it, thanks to the web guy who edited it before.

you can alredy do this in aseprite normally… the outline tool, SHIFT + O

Yes.

Haha, the quickness of the script is simplifying some operation. I don’t need to change the foreground colour, also don’t need to SHIFT + O then press enter again.
Since I’ve been drawing NGP style images lately, so I think the quicker outlines are practical. Maybe there will be a netizen with the same need?
list_Mack