Skip to main content

A lightweight library for simulating digital image decay.

Project description

BitRot: Digital Entropy Library

PyPI - Version PyPI - License Python Downloads

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:

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.8.tar.gz (4.2 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.8-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.8.tar.gz
  • Upload date:
  • Size: 4.2 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.8.tar.gz
Algorithm Hash digest
SHA256 1c846182471335d037f21e77cfeb216ca89a4572b6fb4e27e2c10323920c8bb6
MD5 5115e74b7aedde3ea6ad5e65d9ce5791
BLAKE2b-256 bd02ad294947e0847ab33cb34ffa654810e5dec086a642bfbbc609f64b2901c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 4.4 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 16d335fa1e9f16080cf59ed7b901f016057a673cd3a74ffbff8cc6e6ed3e1906
MD5 d8293d6a0d87e243b28d57a30b279536
BLAKE2b-256 06afe7f9826e7ee98f8f3447f719010bdb08b5430ee8b2f3f3b367160b1ae724

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