Gif disposal for source sprites with translucent pixels

When an RGB color mode sprite contains translucent pixels, the gif generated on export does not properly dispose of frames.

builtIn

Test animation sourced from Makoto/Sprites | Street Fighter Wiki | Fandom .

prepped

For expected result, a script can be used to prepare the sprite. (Convert to indexed with a dither and a palette that has only one transparent color swatch and all others opaque.) For an animation, Bayer ordered dithering would be preferred over FS error diffusion, but I didn’t see any way to get Bayer to support alpha.

My initial guess would be that there are several places in this method where alphas are being compared without a threshold filter applied, i.e., a’ = a >= 128 ? 255 : 0 . Unless, that is, the alpha has been filtered in a prior step.

(Secondarily, the disposal method is from the gif 89 spec. Aseprite writes an 87 header. I don’t know that it’d matter to most modern importers, though.)

1 Like

Thanks @behreandtjeremy. This is a known issue: GIFs currently don’t support transparency at intermediate levels. Currently, Aseprite uses a simple (perhaps overly simple) criterion to determine whether a pixel should be rendered as transparent or opaque:
If alpha < 128 then the pixel color is assumed transparent;
else the pixel is opaque.
Therefore, if the artist wants to simulate transparency, they will need to perform dithering before exporting. Perhaps it would be helpful to add an option to include dithering in the GIF export process.
This report reminded me of the issue: Issue with Transparency on Gifs · Issue #1438 · aseprite/aseprite · GitHub

On the other hand, as you showed in the first gif, there is a bug. I created an issue for this GIF export broken when there are pixels with alpha <128 · Issue #5142 · aseprite/aseprite · GitHub.

Finally the Gif87/Gif89 spec, there is an open issue about this Aseprite always stamps GIF87a version in the file header when saving in GIF format · Issue #4746 · aseprite/aseprite · GitHub

1 Like