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

Uploaded Python 3

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.9.tar.gz
  • Upload date:
  • Size: 4.0 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.9.tar.gz
Algorithm Hash digest
SHA256 cad4533f023d86196bd81cced838cc9cae0ce411f5fafa2525b8dc87d50111dd
MD5 d55de4d45a275c387c0e44c368ffba96
BLAKE2b-256 ce04b21184bcf30857fdbc8ef214ee1c6ed866da7e2cb044fbdcd94ef803d4d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bitrot_decay-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.0 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 19d9234d4cce5ccbc0a8f22e86fd73c1693f41eac42afb5d3c502b0a7eb28f79
MD5 0940d3669e37f36883fe02533916204d
BLAKE2b-256 236b651e59d7ac0b9fafb0c286aa3eb1896ffe1e8edface64bebfba6df478d0a

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