User Rating 0.0
Total Usage 0 times
Quick Colors
1 / 1
Encoding...
Is this tool helpful?

Your feedback helps us improve.

About

GIF89a remains the only universally supported animated image format with no playback dependency on JavaScript or video codecs. This tool implements the full GIF89a binary specification client-side: median-cut color quantization reduces each frame to a 256-color palette, then Lempel-Ziv-Welch (LZW) compression encodes pixel indices into variable-length codes. A malformed global color table or incorrect sub-block chunking produces corrupted files that fail silently in browsers. The encoder handles disposal methods, frame delays in 10ms increments, and transparent color indices. This tool approximates professional output assuming input frames share a similar color distribution; wildly divergent palettes across frames may produce banding artifacts despite Floyd-Steinberg dithering.

Pro tip: GIF frame delays below 20ms are clamped to 100ms by most browsers. Target 50 - 100ms per frame for reliable cross-platform playback. Canvas dimensions above 512×512 with many frames will increase encoding time and file size substantially.

gif creator gif maker animated gif pixel art gif frame animation gif encoder draw gif online

Formulas

GIF uses LZW compression to encode indexed pixel streams. The initial code size is derived from the palette bit depth:

minCodeSize = max(2, ceil(log2(paletteSize)))

The LZW encoder emits variable-length codes starting at minCodeSize + 1 bits, growing up to 12 bits. A Clear Code (2minCodeSize) resets the dictionary when the code table reaches 4096 entries. The End-of-Information code is Clear Code + 1.

clearCode = 2minCodeSize
eoiCode = clearCode + 1

Color quantization uses median-cut partitioning. The RGB color space is recursively bisected along its longest axis. For n target colors, the algorithm performs log2(n) splits, then maps each original pixel to the nearest centroid via Euclidean distance:

d = (r1 r2)2 + (g1 g2)2 + (b1 b2)2

Frame delay in the Graphic Control Extension is stored as a 16-bit unsigned little-endian integer representing hundredths of a second:

delayValue = ms10

Where r, g, b are RGB channel values, d is color distance, paletteSize is the number of quantized colors, and ms is the desired frame delay in milliseconds.

Reference Data

ParameterGIF89a SpecificationPractical Notes
Max Colors per Frame256 (indexed palette)Use dithering for photographic content
Color Table Size21 to 28 entriesSmaller tables reduce file size
Frame Delay Unit10ms incrementsDelay = 0 treated as ~100ms by browsers
Min Reliable Delay20ms (50fps)Chrome/Firefox clamp lower values
Recommended Delay50 - 100ms10 - 20fps is standard
LZW Min Code Size2 - 8 bitsDerived from color table size
LZW Max Code Size12 bits (4096 entries)Table resets via Clear Code
Max Image Dimension65535×65535pxPractical limit ~1024px for web
Transparency1 color index per frameBinary transparency only (no alpha)
Disposal Method 0No disposal specifiedRenderer decides behavior
Disposal Method 1Do not disposeFrame persists under next frame
Disposal Method 2Restore to backgroundClears frame area before next
Disposal Method 3Restore to previousRarely supported correctly
LoopingNetscape Application Extension0 = infinite loop
Sub-block SizeMax 255 bytes per sub-blockData split into chunks
File SignatureGIF89a (6 bytes)GIF87a lacks animation support
Typical Web GIF Size64 - 320pxEmoji/reaction GIF sweet spot
Compression Ratio~40 - 60%Flat colors compress best
Max Practical FramesNo spec limit50 - 100 frames for reasonable file size
Interlacing4-pass Adam7-like schemeRarely used for animated GIFs

Frequently Asked Questions

GIF supports only 256 colors per frame. When a frame contains more colors, median-cut quantization must discard color information. Enable Floyd-Steinberg dithering to distribute quantization error across neighboring pixels, which reduces visible banding. Frames with smooth gradients are most susceptible. Using flat, distinct colors produces the cleanest results.
The GIF specification stores frame delays in 10ms increments. Browsers clamp delays below 20ms to approximately 100ms. The preview in this tool uses requestAnimationFrame which is more precise. For consistent playback, keep frame delays at 50ms or above (≤20 fps). A delay value of 0 in the GIF spec is implementation-dependent and typically rendered as 100ms.
LZW builds a dictionary of recurring pixel sequences. Large areas of identical color produce long repeated runs, yielding high compression. Noisy or photographic content generates short, unique sequences that bloat the dictionary and produce poor compression. For smallest file sizes, use fewer colors, avoid anti-aliased edges, and prefer flat fills over gradients.
The GIF specification imposes no frame count limit. This tool caps at 100 frames to manage browser memory. A 256×256 pixel GIF at 50 frames typically produces a 200KB - 2MB file depending on content complexity. Each frame stores a full indexed pixel array in memory (width × height bytes), so a 512×512 canvas with 100 frames consumes approximately 25MB of RAM before encoding.
Yes. Use the Import Image button to load PNG, JPEG, or WebP files. Each imported image is drawn onto the canvas at the current dimensions, scaled to fit. If the imported image has more than 256 colors, quantization occurs during GIF encoding. For best results, import images that match your canvas dimensions to avoid scaling artifacts.
Onion skinning overlays the previous frame at reduced opacity (typically 30%) beneath your current drawing. This provides reference for smooth motion between frames - essential for walk cycles, morphing shapes, or any animation requiring spatial continuity. Disable it when working on frames that are intentionally discontinuous, such as scene cuts or text cards.