encode | decode | compress

> rle | compress | repeat <

// Run-Length Encoding - Simple compression for repetitive data

[COMPRESS]

Data Compression

Reduce file size by encoding repetitive sequences efficiently.

[SIMPLE]

Simple Algorithm

Fast and straightforward compression with minimal overhead.

[FORMATS]

Multiple Formats

Support for Simple RLE and PackBits (TIFF) formats.

>> technical info

How RLE Works:

Run-Length Encoding replaces sequences of repeated data with a count and single value. Simple RLE uses count+value pairs, while PackBits uses control bytes to distinguish between runs and literals.

Compression Example:

Simple RLE: AAAABBBCC → 4A3B2C ABCDE → 1A1B1C1D1E PackBits: [Run] AAA → FD 41 (3 × 'A') [Literal] ABC → 02 41 42 43

Why Use RLE:

  • >Image compression (BMP, PCX, TIFF)
  • >Fax transmission
  • >Icon and sprite storage
  • >Sparse data compression
  • >Simple to implement

>> frequently asked questions

What is Run-Length Encoding?

RLE is a simple compression algorithm that replaces consecutive identical elements with a count and single copy. It's effective for data with many repetitions like simple graphics or sparse matrices.

Simple vs PackBits RLE?

Simple RLE uses count+value pairs (4A = AAAA). PackBits uses control bytes: negative for runs, positive for literals. PackBits is used in TIFF images and handles mixed data better.

When is RLE effective?

RLE works best with data containing long runs of repeated values. It's inefficient for random data and can actually increase size if there are no repetitions.

RLE vs other compression?

RLE is simpler but less effective than LZ77 or Huffman coding. It's often used as a preprocessing step or for specific formats like fax transmissions where simplicity matters.

Other Languages