'Scale' param in app.command.SaveFileCopyAs does nothing?

Hello there,

When I make a sprite, I usually like exporting it in 100%, 200% 300% and 400% size for ease of use and visibility. I made a simple script for that.

for i = 1,4,1 do
  local fn = path .. '/' .. title .. '-' .. i .. 'x'
  app.command.SaveFileCopyAs{
    useUI=false,
    scale=i;
    filename=fn .. '.png'
  }
end

… But the “scale” parameter seems to do nothing at all, no matter what I set the value at. I’ve checked this out, so I know there is a parameter called scale and its default value is 1.0, but setting it to, for example, 2.0, seems to do nothing.

Throw me a bone, please? Much appreciated.

Hi @Karv,

Welcome aboard! I tried this out:

local activeSprite = app.activeSprite
if not activeSprite then return end

local activeFrame = app.activeFrame
    or activeSprite.frames[1]

local palette = activeSprite.palettes[1]

local blit = Image(activeSprite.spec)
blit:drawSprite(activeSprite, activeFrame)

local path = "mypath\\"
local title = "blah"
local format = ".png"

for i = 1, 4, 1 do
    local scaled = blit:clone()
    scaled:resize {
        width = scaled.width * i,
        height = scaled.height * i
    }

    scaled:saveAs {
        filename = path .. title .. i .. format,
        palette = palette
    }
end

I try to avoid commands whenever possible for reasons like this.

(Obviously there’s inefficiency in the script above, since there’s no need clone and scale an image by 1x, but you get the point.)

Best,
Jeremy

2 Likes

Hi, Jeremy

This does work, and I’m very grateful for your answer! But I’m still a bit irked as to why the scale parameter doesn’t work… I should change the thread title.

Once again, thanks for the help, the script works wonders.

If you’d like to pursue the bug further, what version of Aseprite are you using? I tried app.command.SaveFileCopyAs in 1.3-beta20 and the results were scaled properly. In 1.2.35 they weren’t. There might be a clue in the commit history for the source code you linked above.

Anwho, glad I could help you some. :slight_smile:

1 Like

I’m using 1.3-beta16. I’m updating to 1.3-beta20 as I type this post… Annnnd it works. Wild.

Case closed, everybody! Great job.
Thanks again!

1 Like