Skip to content

Instantly share code, notes, and snippets.

@dacap
Created November 25, 2019 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacap/764c5b026b1293282299a9246c451c89 to your computer and use it in GitHub Desktop.
Save dacap/764c5b026b1293282299a9246c451c89 to your computer and use it in GitHub Desktop.
Export the active sprite to a png file scaling it to 2000%
local orig = app.activeSprite
if not orig then print("There is no active sprite to resize") end
local function replace_extension(path, newext)
local file, ext = string.match(path, "(.-)([^.]*)$")
if file and ext and file ~= "" and ext ~= "" then
return file .. newext
else
return path .. '.' .. newext
end
end
local spr = Sprite(orig) -- Duplicate sprite
spr:resize{ width=20*orig.width, height=20*orig.height }
spr:saveAs(replace_extension(orig.filename, 'png'))
spr:close()
app.activeSprite = orig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment