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.7.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.7-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.7.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.7.tar.gz
Algorithm Hash digest
SHA256 f7c6ff4b0049e84a5d3d9a8d044edfe80fae5752c177fb4df9dea3825aa140b4
MD5 70973c03eddb847bfec55da9a625678d
BLAKE2b-256 d78c20349a482af70a67a39a35f46955009a21ab48287cbcf6a32efd2e98b91d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ec9523b2a668882e570f895d192e87afe8b961033456ec0031e62b7377e49781
MD5 75f177ff5b2c795a1bafbaaed8508788
BLAKE2b-256 ac8603fd492aa164f144d34592c4d81789506339b080921f1b16e89002722efd

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