Skip to main content

A lightweight library for simulating digital image decay.

Project description

## BitRot: Digital Entropy Library

![PyPI - Version](https://img.shields.io/pypi/v/bitrot-decay?style=flat-square&color=00ff41)
![PyPI - License](https://img.shields.io/pypi/l/bitrot-decay?style=flat-square&color=white)
![Python](https://img.shields.io/badge/python-3.7+-blue?style=flat-square&logo=python&logoColor=white)
![Downloads](https://img.shields.io/pypi/dm/bitrot-decay?style=flat-square&color=gray)

**BitRot** is a lightweight, zero-dependency Python library designed to simulate **digital decay**. It intentionally degrades images using bit-crushing, grain injection, and glitch artifacts to simulate file corruption, data rot, and transmission errors.

Unlike standard filters that just add noise, BitRot treats the image as a dying signal, applying structural damage that mimics "bad sectors" and "bit loss" over time.

### 🎯 Use Cases
* **Generative Art:** Create glitch art or "haunted" digital artifacts.
* **Game Development:** Simulate damaged data logs, corrupted HUDs, or dying transmissions.
* **Data Science:** Test machine learning model robustness against noisy or corrupted inputs (adversarial testing).
* **Archival Simulation:** Visualize the theoretical degradation of digital media over time.

---

## 📦 Installation

Install easily via pip:

```bash
pip install bitrot-decay

🚀 Quick Start

1. File-to-File (CLI Style)

The simplest method. Takes an input file, applies decay based on an integrity score, and saves the result.

import bitrot

# integrity: float between 1.0 (Perfect) and 0.0 (Destroyed)
bitrot.decay_file(
    input_path="assets/photo.jpg",
    output_path="assets/photo_rotted.jpg",
    integrity=0.4
)

2. Memory-to-Memory (API Style)

Ideal for web servers (FastAPI/Flask) or real-time processing where you don't want to save files to disk. Accepts raw bytes and returns raw bytes.

import bitrot

# 1. Load image as bytes
with open("source.jpg", "rb") as f:
    raw_data = f.read()

# 2. Rot the bytes directly
# Returns the raw bytes of the decayed JPEG
corrupted_data = bitrot.decay_bytes(raw_data, integrity=0.15)

# 3. Use the bytes (e.g., send to frontend, save to DB, etc.)
with open("output.jpg", "wb") as f:
    f.write(corrupted_data)

Features & Mechanics

Feature Description Trigger Condition
Grain Injection Simulates sensor noise and film grain. Active at all decay levels (< 1.0).
Bit Glitching Randomly shifts pixel blocks to mimic data loss. Triggers when integrity drops below 0.5.
Chroma Decay Desaturates colors to simulate fading memory. Triggers when integrity drops below 0.8.
Safe Clamping Ensures pixel values stay within valid ranges. Always Active.

Contributing

This project is open source and we welcome contributions!

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

License

Distributed under the MIT License. See LICENSE for more information.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitrot_decay-0.0.6.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitrot_decay-0.0.6-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file bitrot_decay-0.0.6.tar.gz.

File metadata

  • Download URL: bitrot_decay-0.0.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for bitrot_decay-0.0.6.tar.gz
Algorithm Hash digest
SHA256 bcf75bb95b2cdf5396db772655563557e178d3dee62850def59cdcf6c7a1bd87
MD5 6bf1379e3ea76b7ccdfde727bbd0cf99
BLAKE2b-256 16057a12da1763dad3c93b703c90a1d6bf3ae3c78ebbbfc387912fe0b53c0b6c

See more details on using hashes here.

File details

Details for the file bitrot_decay-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: bitrot_decay-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for bitrot_decay-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e5b30d99a65b74037ee7e255e9db0afede017a8cdbc5cbbbe2614136054307f4
MD5 a69ea0d45ed0d1b1dca52a0b0a4a34fb
BLAKE2b-256 ad681aa04d5f08e25aa365596105da6c0eb38a47626c3c61f2e434efd97f826e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page