14 releases
| 0.6.0 | Dec 21, 2025 |
|---|---|
| 0.5.0 | Jan 10, 2025 |
| 0.3.1 | Sep 8, 2024 |
| 0.3.0 | Jul 3, 2024 |
| 0.1.3 | Jan 22, 2024 |
#742 in Images
Used in 2 crates
3.5MB
1.5K
SLoC
png-glitch
A library to glitch PNG files. This library is inspired by the pnglitch, a Ruby library to glitch PNG images.
Please visit "The Art of PNG Glitch" for more details about glitching PNG images.

The original image:

Data Structures
+-----------------+
| PngGlitch |
+-----------------+
|
v
+-----------------+
| Png |
+-----------------+
|
+--------------------+--------------------+--------------------+
| | | |
v v v v
+-----------------+ +-----------------+ +-----------------+ +-----------------+
| Header | | Terminator | | Chunk | | ScanLine[] |
+-----------------+ +-----------------+ +-----------------+ +-----------------+
| | | |
v v v v
+-----------------+ +-----------------+ +-----------------+ +-----------------+
| MetaData | | Chunk | | ChunkType | | FilterType |
+-----------------+ +-----------------+ +-----------------+ +-----------------+
|
v
+-----------------+
| ColorType |
+-----------------+
Example usage
The following snippet glitches ./a_png_file.png by
- Changing filter method of all scan lines
- Setting
1to the 4th byte of each scan line
The glitched image is emitted to ./glitched.png.
use png_glitch::{FilterType, PngGlitch};
let mut png_glitch = PngGlitch::open("./a_png_file.png")?;
png_glitch.foreach_scanline(|scan_line|{
scan_line.set_filter_type(FilterType::None);
scan_line[4] = 1;
});
png_glitch.save("./glitched.png")?;
Contribution
- Fork the repository.
- Create a feature branch on your forked repository with
git checkout -b feature-namecommand. - Develop the feature.
- Commit your changes with
git commitcommand. - Upload the feature branch to GitHub and create a pull request.
License
Please refer to the LICENSE file.