[command] Ignore empty frames when saving


Hi everyone,

I’m doing exports out of aseprite files with the CLI, and I’ve got a lot of empty frames spread across all my animations. When I export those frames it makes quit a load of empty images.
I found that there was a ‘–ignore empty’ funtion in the CLI that supposedly would get rid of them, but I don’t get how to use it.

Do someone has an idea ?


Actually the --ignore-empty option is useful only for --sheet and not for --save-as.

Anyway I’m not sure how a --save-as ignoring empty frames could work. For example, how would you know how much frames the animation have if there are empty slots between frames? E.g. Having


How do we know that frame03.pngframe09.png are empty frames? Does frame11.png is an empty frame? Or the last frame is frame10.png? How many frames does this animation have?


I’d assume the frame number is set by the position of the frame inside of a given tag.
Once the frame is numbered, it can be deleted if it’s empty. We’d indeed get gaps in the sequence but it doesn’t matter in our case.

That’s pretty specific to our pipeline.
We’re actually exporting every frame of all our *.ase files in order to pack them in a big atlas.
The probleme is that we have a lot of un wanted blank frames in our animations.

I looked for a way to delete blank image files in bash (now that I’ve been converted :slight_smile:), but couldn’t find anything so far.


I konw it’s not directely aseprite related but maybe you could help me with that.
Here’s what I found :

    for file in D:/00_TAKROG/ATLAS_UNITS_AND_DOODADS_TEMPORARY/*.png; do
      histogram=`convert "$file" -threshold 50% -format %c histogram:info:-`
      white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
      black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
      blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
      if [ ${blank} -eq "1" ]; then
        echo "$file seems to be blank - removing it..."
        rm "$file"

This is where I found this piece of code.

It doens’t work but I don’t know why.
Here’s the error I get for every file in the folder.

    Paramètre non valide - /00_TAKROG
    bash: bc: command not found
    bash: [: -eq: unary operator expected



I went a little further and now I miss just a little something.

      	  convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:

This returns 1 if the image is NOT blank and 0 if the image IS blank. But I don’t know how to use the returned value in an if statement.

I know this :

      	convert "$file" -threshold X% -format "%[fx:mean==1?1:0]" info:
			if [ ??? = "0" ]; then
				echo "$file seems to be blank - removing it..."
				rm "$file"


But I don’t know what to put in place of the ???.

[EDIT] It uses ImageMagick to do the operations.


That’s it !

For anyone chiming in, here’s what to do to delete empty images in a given folder in windows, in bash.

    test=$(convert "$file" -alpha extract -format "%[fx:mean==0?0:1]" info:)
	if [ "$test" = "0" ]; then
		rm "$file"

David, if you end up adding a feature to ignore empty frame at export/saving, I’ll be pretty happy because even if I don’t have to do anything now, automatic deletion takes several tenth of minutes (over 9000 files to check, and around 4000 files to delete).
Anyway, thanks for your help, your awesome :slight_smile:



It’s nice that you’ve found a work around :+1: I’ll try to add --ignore-empty support for --save-as too for the next version.


Man you deserve a statue ! :smiley:
That would help us a lot indeed, we just ran a test and it takes over 45 minutes to delete all the empty images.
Thanks again !

Best regards !