Crate pnm

Source
Expand description

crate for decoding/encoding the portable anymap format.

§a quick guide to the various functions for everyday use

  • decode(): your go-to for all PNM image decoding. If you have a specific format you need to support, use its module directly. Note that this function reads both plain and raw formats.
  • encode(): this function is a little tricky. It supports the “older” PNM formats, and, due to their age they do not support the alpha channels existence. If possible, use pam::encode instead.
  • encode_plain: The PAM format doesnt actually support read-age-by-humans, so this is still useful at times. Outputs data in decimal digits.

§functions in action

let data = include_bytes!("../tdata/fimg-rainbowR.ppm");
let out = pnm::decode(data).unwrap();

assert_eq!(pnm::encode(out), data);

Modules§

decode
decoding utilities
pam
Portable Arbitrary Format RGB (no alpha) image encoding and decoding.
pbm
Portable BitMap Format black and white image encoding and decoding.
pgm
Portable GreyMap Format grey image encoding and decoding.
ppm
Portable PixMap Format RGB (no alpha) image encoding and decoding.

Functions§

decode
Decode any pgm, ppm, pbm, pam image.
encode
Encodes an image to one of the pgm or ppm portable anymap formats.
encode_plain
Encodes an image to one of the pgm or ppm portable anymap formats.