📄 NVGIFv4 Specification

← Back to Specifications

🧠 Header (11 bytes)

Offset (bytes) Length (bytes) Field Description
0 3 Magic ASCII "NVG"
3 1 Version 0x04 for NVGIFv4
4 1 Compression Compression type (see below)
5 1 Alpha 0 = off (RGB), 1 = on (RGBA)
6 2 Width Unsigned big-endian 16-bit integer
8 2 Height Unsigned big-endian 16-bit integer
10 1 Reserved Always 0x00 in v4

💾 Compression Types (byte 4)

Value Name Description
0 None Raw row data, length-prefixed per row
1 RLE Run-Length Encoded rows, each prefixed with 2-byte length
2 Zlib Entire image buffer compressed with zlib.compress()
3 RLE+Zlib Each row RLE-encoded and length-prefixed, then full buffer zlib-compressed

🎨 Pixel Data


🧱 Payload Encoding

Compression 0 (None)

Compression 1 (RLE)

Compression 2 (Zlib)

Compression 3 (RLE + Zlib)


🔄 Decoding Logic (Summary)

  1. Read and validate magic bytes and version
  2. Parse compression, alpha, dimensions
  3. Decompress payload based on compression
  4. Build final buffer (RGB or RGBA)
  5. Return usable image (e.g. via Pillow)

🚀 Notes


📌 Example Header (Hex Dump)

4E 56 47 04 03 00 00 C8 00 C8 00

🧃 This Spec Supports