pngyou/lib.rs
1//! # PNG You!
2//!
3//! A simple, high-performance library to hide secret messages in a PNG file using steganography.
4//!
5//! ## How it works
6//! Every PNG file is divided into chunks following specific rules (see [PNG Struct Spec]).
7//! It is, therefore, possible to append our own chunks of data inside a PNG without removing its validity.
8//! The crate makes use of this to "hide" data inside a PNG file easily.
9//!
10//! ## Quick Example
11//! ```no_run
12//! use pngyou::{Png, Chunk, ChunkType};
13//! use std::str::FromStr;
14//! use std::convert::TryFrom;
15//!
16//! fn main() -> Result<(), Box<dyn std::error::Error>> {
17//! // Load your PNG file from bytes
18//! let input_bytes = std::fs::read("input.png")?;
19//! let mut png = Png::try_from(input_bytes.as_slice())?;
20//!
21//! // Create a custom chunk type and your secret message
22//! let chunk_type = ChunkType::from_str("RuSt")?;
23//! let message = "This is a secret message".as_bytes().to_vec();
24//!
25//! // Create the chunk and append it to the PNG
26//! let new_chunk = Chunk::new(chunk_type, message);
27//! png.append_chunk(new_chunk);
28//!
29//! // Save the modified PNG back to a file
30//! std::fs::write("output.png", png.as_bytes())?;
31//!
32//! Ok(())
33//! }
34//! ```
35//!
36//! ## Features
37//!
38//! - **PNG Specification Compliance:** Strict parsing and validation of PNG
39//! structure and chunk types according to the PNG specification.
40//!
41//! - **Chunk Abstractions:** Strongly-typed representations for PNG chunks
42//! and chunk types, with semantic validation (critical, public, safe-to-copy).
43//!
44//! - **Safe Chunk Manipulation:** Create, insert, remove, and query chunks
45//! without corrupting the PNG file structure.
46//!
47//! - **CRC Integrity:** Automatic computation and verification of CRC values
48//! to preserve file correctness.
49//!
50//! - **Steganography-Friendly:** Designed to support custom chunks
51//! for data embedding without breaking image decoders.
52//!
53//! - **Extensible Design:** Can be used for general PNG inspection, editing,
54//! and tooling beyond steganography use cases.
55//!
56//! ## CLI Interface
57//!
58//! See the `pngyou` binary for end user usage examples.
59//!
60//! [PNG Struct Spec]: https://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html
61
62mod chunk;
63mod chunk_type;
64mod png;
65
66pub use chunk::Chunk;
67pub use chunk_type::ChunkType;
68pub use png::Png;