micropnm

Crates.iomicropnm
lib.rsmicropnm
version0.1.0
sourcesrc
created_at2023-05-04 19:01:26.998782
updated_at2023-05-04 19:01:26.998782
descriptionMicroPNM is a lightweight, zero-dependency Rust crate for parsing binary PPM image files. It is designed to with minimal memory usage and is suitable for embedded contexts and WebAssembly.
homepage
repository
max_upload_size
id857018
size21,457
Arne Winter (arnemileswinter)

documentation

README

MicroPNM πŸŽ¨πŸ’»

Rust Crates.io GitHub issues GitHub pull requests

MicroPNM is a small and efficient library for parsing PNM image formats in Rust. πŸ¦€ It is designed to be minimalistic and highly optimized for resource-constrained systems, πŸ” making it suitable for embedded contexts and WebAssembly using the include_bytes! macro. πŸ’ͺ

At the moment, only reading of binary PPM (P6) is supported. 🚫

Usage πŸ› οΈ

Add the following to your Cargo.toml file:

[dependencies]
micropnm = "0.1.0"

In your Rust code, use it like this:

use micropnm::PNMImage;

let raw_img = include_bytes!("./path/to/your/binary_image.ppm");
let ppm_img = PNMImage::from_parse(raw_img).unwrap();

// Get the image dimensions
let width = ppm_img.width();
let height = ppm_img.height();

// Get the maximum pixel value
let max_pixel = ppm_img.maximum_pixel();

// Get the image comment
let comment = ppm_img.comment();

// Get the RGB value of a pixel
let (r, g, b) = ppm_img.pixel_rgb(10, 20).unwrap();

Minimal Allocations πŸ§‘β€πŸ’»

MicroPNM is designed with minimal memory usage in mind. πŸ’­ This makes it suitable for use in embedded contexts or in WebAssembly modules. πŸ•ΈοΈ The PNMImage type itself is simply a thin wrapper around a byte slice of raw image data. πŸ’Ύ

License πŸ“œ

This library is licensed under the MIT license.

Commit count: 0

cargo fmt