Staaarter

GIF Edge Cleaner

Uploads an animated GIF and cleans up stray semi-transparent fringe pixels near every frame's alpha edges: near-0 alpha values snap to fully transparent, near-255 values snap to fully opaque, while genuine mid-range (intentional soft-edge) alpha is left untouched, then re-encodes and downloads the result. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-29
By Staaarter Team
editoredgesanimationcanvasgiftransparency

Overview

Introduction

This tool cleans up stray semi-transparent fringe pixels near an animated GIF's alpha edges, entirely client-side, without blurring or blending anything.

It's a targeted cleanup step: near-0 alpha snaps down to fully transparent, near-255 alpha snaps up to fully opaque, and everything genuinely in between is left untouched.

What Is GIF Edge Cleaner?

A client-side GIF alpha-cleanup tool that, for every frame, reclassifies pixels whose alpha is below a low threshold or above a high threshold (and, by default, that also sit within a small radius of a hard 0/255 boundary), snapping them the rest of the way to fully transparent or fully opaque.

Setting the edge search radius to 0 applies the same threshold snapping across the whole frame rather than only near hard boundaries.

How GIF Edge Cleaner Works

For each pixel, its alpha is compared against `lowThreshold` and `highThreshold`. A pixel below the low threshold (but not already 0) or above the high threshold (but not already 255) is flagged as a stray candidate.

If `edgeRadius` is greater than 0, a flagged pixel is only actually snapped if a genuinely fully-transparent or fully-opaque pixel is found within that radius (confirming it's really fringe near a hard edge, not an intentional mid-range gradient); with `edgeRadius` set to 0, every flagged pixel is snapped unconditionally.

When To Use GIF Edge Cleaner

Use it on a GIF that shows a faint halo or ring of slightly-transparent pixels around an otherwise hard-edged subject, often left over from a lossy export or an earlier background-removal pass.

It's also a good final cleanup step after using the GIF Background Remover or GIF Chroma Key Remover, since color-distance-based keying can leave a thin ring of partial transparency at the boundary.

Features

Advantages

  • Never blurs or blends color, unlike the GIF Edge Refiner: only alpha values are reclassified.
  • Leaves genuine mid-range alpha (intentional soft edges or feathers) completely untouched.
  • Runs entirely client-side; the uploaded animation is never sent to a server.

Limitations

  • Won't fix a genuinely soft or intentionally feathered edge: by design, it only targets near-0/near-255 stray values, not real mid-range alpha.
  • Choosing thresholds too close to 128 can start snapping pixels that were meant to stay semi-transparent.

Examples

Clean up a chroma-key halo

Input

A 160x160 animated GIF with a faint semi-transparent green-tinted ring left after background removal, low threshold 32, high threshold 223, edge radius 3

Output

A 160x160 animated GIF with the faint ring snapped to fully transparent, leaving a clean hard edge

The stray near-0-alpha ring pixels near the hard silhouette boundary are cleared; the subject's fully opaque interior is untouched.

Best Practices & Notes

Best Practices

  • Run this after a background-removal or chroma-key pass, since those operations are the most common source of stray fringe pixels.
  • Keep the default thresholds (32 and 223) unless you have a specific reason to be more or less aggressive.
  • Use edge radius 0 only if you're confident there's no intentional mid-range alpha anywhere in the frame, since it applies globally.

Developer Notes

cleanGifEdgeFringe in gif-edge-cleaner.ts maps either cleanFrameFringe (global, unconditional threshold snap, used when edgeRadius is 0) or cleanFrameEdgeFringe (the same snap but gated on proximity to a genuinely hard 0/255 neighbor) across every frame of a DecodedGif. Unlike gif-edge-refiner.ts and gif-edge-feather.ts, this file never touches RGB values or performs any weighted averaging: it's a pure per-pixel alpha reclassification.

GIF Edge Cleaner Use Cases

  • Cleaning up a faint semi-transparent halo left after chroma-key or color-distance background removal
  • Removing lossy-re-encoding fringe artifacts around a GIF's silhouette
  • Tightening up alpha values before re-encoding a GIF through another lossy tool

Common Mistakes

  • Setting the low/high thresholds too close to 128, accidentally snapping genuinely intentional mid-range alpha.
  • Using edge radius 0 on a frame that has an intentional feathered or soft-shadow region, flattening it unintentionally.

Tips

  • Run the GIF Background Remover or GIF Chroma Key Remover first, then this tool as a follow-up cleanup pass.
  • If you want an intentional soft edge instead of a clean hard one, use the GIF Edge Feather tool instead of tightening thresholds here.

References

Frequently Asked Questions