Skip to content
Python script that puts glitch effects into PNG files
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
pngglitch
.gitignore
CHANGELOG
COPYING
README.rst
setup.py

README.rst

Pngglitch

A Python script that puts glitch effects into PNG files.

Usage on the command-line:

  • pngglitch input.png

    Introduces glitches into the file input.png and saves the result as input.corrupted.png.

  • pngglitch -o output.png input.png

    Introduces glitches into the file input.png and saves the result as output.png.

  • pngglitch -N 10 input.png

    Makes 10 different attempts at glitching the file input.png. The resulting files are saves as input.0.png through input.9.png.

  • pngglitch -N 10 -o "corrupt file %d.png" input.png

    Makes 10 different attempts at glitching the file input.png. The resulting files are saves as corrupt file 0.png through corrupt file 9.png.

    The parameters -a, -m, and -d change the amount, size and size variation of glitches. Just play around with them and see what has the best results.

Usage in Python:

This script offers a class GlitchedPNGFile that enables the user to partially decompress a PNG file and deliberately put errors into it's bytestream.

The constructor of GlitchedPNGFile takes a PNG file name and reads in the chunks of the given file. After that, you can call the glitch_file() method to insert random errors into the file. The glitch_file() method iterates over the resulting image files. You can write these to disk via their write method.

You can also call various glitch effect methods directly, but you have to wrap these calls between calls to start_glitching() and end_glitching(). The former decompresses the file, the latter compresses it again and portions the data into equally-sized chunks again.

You can’t perform that action at this time.