Skip to content

NotReeceHarris/rgba-data-encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RGBA Data Encoder

This project encodes arbitrary data into PNG images by packing raw bytes into RGBA pixel channels. It works by converting input data into hexadecimal format, then storing two hex characters (one byte) per PNG channel (R, G, B, A), achieving 8 hex characters (4 bytes) of storage per pixel.

The encoding is completely lossless - files can be perfectly reconstructed from the generated images. However, this is not a compression algorithm. For already compressed files like PDFs or videos, the PNG output will typically be slightly larger than the original. For uncompressed text files, the size remains about the same.

Some example encodings are included:

  • doom.pdf encodes to 4.8MB (original 6.2MB) -1.4MB
  • The Bad Apple video encodes to 37.8MB (original 21.7MB) +16.1MB

While this doesn't compress data, it provides an interesting way to represent any file as an image. Potential uses include archival storage, steganography, or simply as a novelty encoding method. The simple byte-level packing ensures reliable round-trips with no data loss.

Below is doom.pdf as a image, in this case data has been compressed:

Doom.pdf as a image

The compression isnt amazing and in most cases it doesnt compress but increases depending on the original data format, for example here is bad apple encoded:

Touhou - Bad Apple

About

Encode data into a PNG using RGBA pixel channels.

Topics

Resources

License

Stars

Watchers

Forks