1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
/* This file is part of jpegxl-rs. jpegxl-rs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. jpegxl-rs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with jpegxl-rs. If not, see <https://www.gnu.org/licenses/>. */ #![deny(missing_docs)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![deny(clippy::all)] //! # Overview //! A safe JPEGXL wrapper over `jpeg-xl` library. Check out the original [library](https://gitlab.com/wg1/jpeg-xl) //! and the [bindings](https://github.com/inflation/jpegxl-sys). //! # Usage //! ## Decoding //! ```rust //! # || -> Result<(), Box<dyn std::error::Error>> { //! use jpegxl_rs::*; //! //! let sample = std::fs::read("test/sample.jxl")?; //! let mut decoder: JXLDecoder<u8> = decoder_builder().build()?; //! let (info, buffer) = decoder.decode(&sample)?; //! # Ok(()) }; //! ``` //! //! Set output pixel paramaters //! ```rust //! // Pixel type is set by type parameter //! # || -> Result<(), Box<dyn std::error::Error>> { //! # use jpegxl_rs::*; //! let mut decoder: JXLDecoder<u16> = decoder_builder() //! .num_channels(3) //! .endian(Endianness::Big) //! .align(8) //! .build()?; //! # Ok(()) }; //! ``` //! ## Encoding //! ```rust //! # use jpegxl_rs::encoder::*; //! # || -> Result<(), Box<dyn std::error::Error>> { //! use image::io::Reader as ImageReader; //! //! let sample = ImageReader::open("test/sample.png")?.decode()?.to_rgba16(); //! let mut encoder = encoder_builder().build()?; //! let buffer: Vec<u8> = encoder.encode( //! &sample, //! sample.width() as _, //! sample.height() as _ //! )?; //! # Ok(()) }; //! ``` //! //! ## [`image`](https://crates.io/crates/image) crate integration //! The integration is enabled by default. If you don't need it, disable `with-image` feature. //! ``` //! # || -> Result<(), Box<dyn std::error::Error>> { //! use jpegxl_rs::image::*; //! //! let sample = std::fs::read("test/sample.jxl")?; //! let decoder: JXLImageDecoder<u16> = JXLImageDecoder::new(&sample)?; //! let img = image::DynamicImage::from_decoder(decoder)?; //! # Ok(()) }; //! ``` mod common; pub mod decoder; pub mod encoder; pub mod error; pub mod memory; pub mod parallel; #[cfg(not(feature = "without-image"))] pub mod image; pub use common::*; pub use decoder::*; pub use encoder::*;