BMP to GIF Converter
Convert BMP images to GIF format instantly in your browser. Client-side conversion with LZW compression, color quantization, and optional dithering.
About
BMP (Bitmap) files store raw, uncompressed pixel data. A 1920×1080 BMP at 24-bit color depth consumes roughly 5.9 MB. GIF (Graphics Interchange Format) applies LZW lossless compression and restricts the palette to 256 colors, typically reducing file size by 60 - 90% for graphics and illustrations. Feeding a photographic BMP into GIF without proper color quantization produces severe banding artifacts. This tool applies Median Cut quantization to extract an optimal 256-color palette, with optional Floyd-Steinberg dithering to mask banding. All processing runs locally in your browser. No files are uploaded to any server.
Limitations: GIF is inherently limited to 256 indexed colors per frame. Photographic content with smooth gradients will show quality loss compared to PNG or JPEG. This converter handles single-frame static GIF output. Transparency is supported by designating one palette index as transparent. Expect encoding times of 1 - 5 seconds for images under 2 MP, scaling linearly with pixel count due to LZW compression overhead.
Formulas
The GIF file format (GIF89a) encodes image data using Lempel-Ziv-Welch (LZW) compression on indexed color data. The encoding pipeline has two critical stages:
Stage 1 - Color Quantization (Median Cut):
The input BMP pixel array P of N pixels, each with channels (R, G, B) ∈ [0, 255], is partitioned into k ≤ 256 clusters. For each cluster, the representative color is the component-wise mean:
Cj = 1|Sj| ∑p ∈ Sj p
Each pixel is then mapped to the nearest palette index by Euclidean distance in RGB space:
idx(p) = argminj √(Rp − Rj)2 + (Gp − Gj)2 + (Bp − Bj)2
Stage 2 - LZW Compression:
The index stream is compressed using LZW with variable-length codes. Initial code size M = max(2, ceil(log2(k))). A dictionary is initialized with 2M + 2 entries (palette indices + Clear Code + EOI Code). Code width starts at M + 1 bits and grows to a maximum of 12 bits (4096 entries). When the dictionary fills, a Clear Code resets it.
Floyd-Steinberg Dithering (optional):
Quantization error e = p − Cidx is diffused to neighboring pixels with weights: right 716, bottom-left 316, bottom 516, bottom-right 116.
Where: P = pixel array, N = total pixel count, k = palette size (≤ 256), Sj = cluster j, Cj = centroid color of cluster j, M = minimum LZW code size, e = quantization error vector.
Reference Data
| Property | BMP | GIF |
|---|---|---|
| Full Name | Bitmap Image File | Graphics Interchange Format |
| Extension | .bmp, .dib | .gif |
| Compression | None (or RLE) | LZW (lossless) |
| Max Colors | 16.7 million (24-bit) | 256 (indexed) |
| Transparency | Via alpha channel (32-bit) | Single-color transparency |
| Animation | Not supported | Supported (multi-frame) |
| Color Depth | 1, 4, 8, 16, 24, 32 bit | 1 to 8 bit |
| File Size (1920×1080) | ≈ 5.9 MB | ≈ 0.3 - 1.5 MB |
| MIME Type | image/bmp | image/gif |
| Specification | Microsoft BMP v5 | GIF89a (1989) |
| LZW Min Code Size | N/A | 2 - 8 bits |
| Max Image Size | Unlimited (OS-bound) | 65535 × 65535 px |
| Best Use Case | Raw editing, Windows icons | Logos, icons, simple graphics |
| Browser Support | Universal | Universal |
| Byte Order | Little-endian | Little-endian |
| Header Magic Bytes | 42 4D ("BM") | 47 49 46 ("GIF") |