| Crates.io | pngv |
| lib.rs | pngv |
| version | 0.1.0 |
| created_at | 2025-11-09 23:59:35.487936+00 |
| updated_at | 2025-11-09 23:59:35.487936+00 |
| description | A library and CLI tool for converting PNG images to color matrices and reconstructing them as PNG or SVG |
| homepage | |
| repository | https://github.com/vmaspad/pngv |
| max_upload_size | |
| id | 1924607 |
| size | 35,157 |
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.
.pngv format) where each cell contains a hex color with alpha channel (#RRGGBBAA).pngv files with 1x1 pixels.pngv filescargo install pngv
Add this to your Cargo.toml:
[dependencies]
pngv = "0.1"
The CLI requires a command and an input file. The output path is optional and will be auto-generated if not provided.
pngv <COMMAND> <INPUT> [OUTPUT]
Convert a PNG image to a color matrix:
pngv encode image.png
# Creates: image.pngv
pngv encode input.png output.pngv
# Creates: output.pngv
Reconstruct a PNG from a color matrix:
pngv decode image.pngv
# Creates: image.png
pngv decode input.pngv output.png
# Creates: output.png
Generate an SVG with 1x1 vector pixels:
pngv svg image.pngv
# Creates: image.svg
pngv svg input.pngv output.svg
# Creates: output.svg
use pngv::{encode_to_pngv, decode_from_pngv, decode_to_svg};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Encode a PNG to .pngv format
encode_to_pngv("image.png", "image.pngv")?;
// Decode back to PNG
decode_from_pngv("image.pngv", "output.png")?;
// Export to SVG
decode_to_svg("image.pngv", "output.svg")?;
Ok(())
}
The .pngv file is a JSON array of arrays, where each element represents a pixel color:
[
["#FF0000FF", "#00FF00FF", "#0000FFFF"],
["#FFFFFFFF", "#000000FF", "#808080FF"]
]
#RRGGBBAA format (Red, Green, Blue, Alpha in hexadecimal)Licensed under either of:
at your option.