GIF Format
Graphics Interchange Format
Block Structure
GIF is one of those formats that has outlived its expected lifespan by decades. Created by CompuServe in 1987, it's still everywhere today, mostly because of its animation support.
The format uses a block-based structure that's refreshingly straightforward compared to modern formats. A header, some descriptors, a color table, your image data, and a single-byte trailer to say "the end."
GIF File Structure
GIF Header
| Offset | Hex | ASCII | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0000 | 4749463839618002E001F70000 | GIF89a....... | ||||||||||||
Version Differences
Original spec. No extension blocks.
Added extensions, animation, transparency.
Extension Blocks
GIF89a (the 1989 revision) added extension blocks, which is how GIF got animation support. All extension blocks start with 0x21 followed by a type byte, which makes them easy to spot when you're scanning through a file. Some of these we want to keep (animation timing), others we want to remove (comments).
Graphic Control Extension (0xF9)
Controls animation timing, transparency, and disposal method. Precedes each image descriptor in animated GIFs. Always preserved.
Comment Extension (0xFE)
Plain text comments. Can contain any information including author, creation date, software, or personal notes. Removed by PicScrub.
Application Extension (0xFF)
Application-specific data. Most important: NETSCAPE2.0 for animation looping. Can also contain XMP metadata.
Plain Text Extension (0x01)
Rarely used. Renders text using the GIF color table. Mostly ignored by modern software.
Application Extensions
NETSCAPE2.0:Animation Loop
Controls how many times an animated GIF loops. Value of 0 means infinite loop.
| Offset | Hex | ASCII | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0000 | 21FF0B4E45545343415045322E300301000000 | !..NETSCAPE2.0..... | ||||||||||||||||||
PicScrub preserves NETSCAPE2.0 to maintain animation behavior.
XMP Data:Extensible Metadata Platform
Application identifier: XMP DataXMP. Contains full XMP/RDF metadata in XML format.
PicScrub removes XMP application extensions.
Animation Preservation
The tricky part with GIF is distinguishing between animation data (which we need to keep) and metadata (which we want to remove). Both live in extension blocks, so we can't just strip all extensions.
Preserved for Animation
- • NETSCAPE2.0 loop count
- • Graphic Control Extensions
- • Frame delays
- • Disposal methods
- • Transparency indices
- • Local color tables
Removed
- • Comment extensions
- • XMP application blocks
- • Unknown application blocks
- • Plain text extensions
How PicScrub Processes GIF
Validate Header
Check for GIF87a or GIF89a signature
Copy Header Data
Preserve LSD and Global Color Table unchanged
Filter Extensions
Keep NETSCAPE2.0 and Graphic Control, remove Comment and XMP
Preserve Image Data
Copy all image descriptors, LCTs, and LZW data unchanged
Write Trailer
End file with 0x3B trailer byte
LZW Compression
A quick note on GIF's image data: it uses LZW compression, which was actually patented until 2004 (causing all sorts of drama in the '90s). PicScrub doesn't touch the compressed data at all. We copy it byte-for-byte, which means zero quality loss.
Why This Matters
By preserving the original LZW data, PicScrub ensures:
- • No quality loss (bit-perfect image preservation)
- • Fast processing (no decode/encode cycle)
- • Identical file size for image data
GIF Metadata Limitations
The good news about GIF is that it predates the EXIF standard, so there's no GPS coordinates or camera info to worry about. The metadata concerns are more mundane.
What Can Leak
GIF's privacy concerns are relatively minor compared to JPEG:
- • Comment extensions (sometimes containing author notes)
- • XMP metadata (rare, but possible)
- • Software identification in application blocks