# Shitpress

Shitpress is a [simple](kiss.md) [compression](compression.md) [algorithm](algorithm.md) and utility made by [drummyfish](drummyfish.md). It is written in [C](c.md) (a version in [comun](comun.md) exists as well), the single header [library](library.md) is under 200 [lines of code](loc.md) and doesn't use any library at all (not even stdlib). Shitpress was made more or less as an educational example when writing the article on compression for [this wiki](lrs_wiki.md), but it turned out to be usable in practice. There is also supershitpress, a utility that uses the same algorithm repeatedly as long as the size gets reduced. Vanilla shitpress reduced the size of a raw website screenshot to 50% of the original size, text usually to around 80% of the original size -- that's nothing awesome, however shitpress works well on very simple data such as binaries and images that contain many repeating constant values and this is what it's meant for: a tiny, modest compression of simple data in very simple programs.

The algorithm works as a [constant time](o1.md) and constant memory stream filter, so it's pretty fast and efficient. The principle is to basically treat the latest history (approx 64 bytes) as a dictionary so that if a sequence (of up to 6 bytes) that recently appeared occurs again, we just reference it with a 2 [byte](byte.md) pointer (so the theoretical best compression ratio is 3).

As of writing this the repository is for example [here](http://git.coom.tech/drummyfish/drummy_stuff/src/branch/master/shitpress).

{ Someone told me brieflz is probably something similar, you can check it out too. ~drummyfish }