pngv
A Rust library and CLI tool for converting PNG images to color matrices and reconstructing them as PNG or SVG files with 1x1 vector pixels.
Features
- Encode: Convert PNG images to JSON color matrices (
.pngvformat) where each cell contains a hex color with alpha channel (#RRGGBBAA) - Decode: Reconstruct PNG images from
.pngvfiles with 1x1 pixels - SVG Export: Generate SVG files with 1x1 vector rectangles from
.pngvfiles - Simple CLI with automatic output path generation
- Can be used as a library in your own projects
Installation
As a CLI tool
As a library
Add this to your Cargo.toml:
[]
= "0.1"
CLI Usage
The CLI requires a command and an input file. The output path is optional and will be auto-generated if not provided.
Basic syntax
Commands
Encode: PNG → .pngv
Convert a PNG image to a color matrix:
# Creates: image.pngv
# Creates: output.pngv
Decode: .pngv → PNG
Reconstruct a PNG from a color matrix:
# Creates: image.png
# Creates: output.png
SVG: .pngv → SVG
Generate an SVG with 1x1 vector pixels:
# Creates: image.svg
# Creates: output.svg
Library Usage
use ;
.pngv Format
The .pngv file is a JSON array of arrays, where each element represents a pixel color:
- Each row represents a horizontal line of pixels (top to bottom)
- Each color is in
#RRGGBBAAformat (Red, Green, Blue, Alpha in hexadecimal) - Alpha channel is fully supported
Use Cases
- Pixel art editing: Edit images as JSON matrices
- Image analysis: Process images as structured data
- Vector conversion: Convert pixel art to scalable SVG format
- Data visualization: Represent images as color data
- Backup/versioning: Store images in text-friendly format
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.