Is there a way to set the default setting of the ‘export as’ to be ‘selected frame’ and ‘png’?
I’m usually exporting single images and I feel I’m always changing this settings.
Ideally I would like to have the option to set different shortcuts for both animation and single frame.
I could probably do it in LUA, but I wanted to be sure there is no native option available.
I created a script that allows to export the current frame as PNG.
It just pops a dialog to set the path and it saves the current frame to that location.
I personnaly made a shortcut to execute the script. I find it very convenient.
local spr = app.activeSprite
if not spr then
app.alert("No active sprite found!")
return
end
local frameNumber = app.activeFrame.frameNumber
if not frameNumber then
app.alert("No active frame selected!")
return
end
-- Create a new temporary sprite with the active frame only
local tmpSprite = Sprite(spr.width, spr.height)
local tmpLayer = tmpSprite.layers[1]
for i, layer in ipairs(spr.layers) do
if layer.isVisible then
local cel = layer:cel(frameNumber)
if cel then
-- Copy the image of the visible cel to the new sprite
tmpLayer = tmpSprite:newLayer()
tmpLayer.name = layer.name
local newCel = tmpSprite:newCel(tmpLayer, 1, cel.image:clone(), Point(cel.position))
newCel.image:drawImage(cel.image)
end
end
end
-- Flatten the temporary sprite to merge all layers
tmpSprite:flatten()
-- Now use the SaveFileAs dialog to save the temporary sprite as a PNG
local function savePng(sprite)
local filename = sprite.filename:match("(.+)%..+$") or "untitled"
filename = filename .. "_frame" .. frameNumber .. ".png"
app.command.SaveFileAs {
filename = filename,
fileFormat = "png"
}
end
savePng(tmpSprite)
-- Clean up: Close the temporary sprite without saving changes
tmpSprite:close()