Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Convert a PNG file into a human-readable RLE format by using Python 3 and Pillow.

If you don't have Pillow installed

Run the following command from the command prompt:
pip install pillow

What is RLE

According to Wikipedia, RLE stands for "Run-length encoding (RLE)".

Run-length encoding is a very simple form of lossless data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run.

For example, this string:

...becomes this after using RLE:

This script simply converts a binary PNG image into an RLE-type file format.


Original image

Sample output
#Image Dimensions
Width: 683 
Height: 384 

#Image Palette 255, 0, 128 0, 102, 0 0, 255, 0 66, 255, 66 0, 0, 255 255, 255, 0 128, 128, 128 0, 0, 0

#Pixel Count 0: 42670 1: 48 0: 631 1: 53 0: 627 1: 61 0: 55 2: 55 0: 509 1: 67 0: 48 2: 63

... truncated for brevity

Included commands

open_png(filename): Open up a PNG file by file path, and read it into memory
get_color_atpoint(point): Get a tuple with RGB values at a given point in an image, by passing in a tuple with X,Y coordinates
read_rle_fromstream(stream): Read in RLE information from a file, by passing in a file stream
write_memory_tofile(filename): Write out the image in memory as a binary file
write_rle_tostream(filename): Write out RLE information to a file, by passing in a file stream


Convert a PNG file into a human-readable RLE format by using Python 3 and Pillow



No releases published


No packages published