1#![doc = include_str!("../README.md")]
2
3mod alpha;
4mod convert;
5mod endian;
6mod error;
7mod format;
8mod image;
9mod loader;
10mod pixel_format;
11mod png;
12
13pub use crate::error::*;
14
15#[cfg(feature = "mozjpeg")]
16mod mozjpeg;
17#[cfg(all(not(feature = "mozjpeg"), feature = "jpeg"))]
18mod jpeg;
19#[cfg(any(feature = "mozjpeg", feature = "jpeg"))]
20mod exif;
21mod profiles;
22
23#[cfg(feature = "avif")]
24mod avif;
25
26#[cfg(feature = "webp")]
27mod webp;
28
29pub use crate::convert::FromOptions;
30pub use crate::format::*;
31pub use crate::image::*;
32pub use crate::loader::*;
33use std::path::Path;
34
35pub fn load_path(path: impl AsRef<Path>) -> Result<Image, Error> {
39 Loader::new().load_path(path)
40}
41
42pub fn load_data(data: &[u8]) -> Result<Image, Error> {
44 Loader::new().load_data(data)
45}
46
47#[doc(hidden)]
48#[deprecated(note = "use load_path or Loader::new()")]
49pub fn load_image(path: impl AsRef<Path>, opaque: bool) -> Result<Image, Error> {
50 Loader::new().opaque(opaque).load_path(path)
51}
52
53#[doc(hidden)]
54#[deprecated(note = "use load_data or Loader::new()")]
55pub fn load_image_data(data: &[u8], opaque: bool) -> Result<Image, Error> {
56 Loader::new().opaque(opaque).load_data(data)
57}
58
59pub mod export {
61 pub mod rgb {
63 pub use ::rgb::*;
64 pub type GRAY16 = ::rgb::Gray<u16>;
65 pub type GRAY8 = ::rgb::Gray<u8>;
66 pub type GRAYA16 = ::rgb::GrayAlpha<u16>;
67 pub type GRAYA8 = ::rgb::GrayAlpha<u8>;
68 }
69
70 pub mod imgref {
72 use super::rgb;
73 pub use imgref::{ImgRef, ImgVec};
74
75 #[derive(Debug, Clone, PartialEq, Eq)]
76 pub enum ImgRefKind<'data> {
77 RGB8(ImgRef<'data, rgb::RGB8>),
78 RGBA8(ImgRef<'data, rgb::RGBA8>),
79 RGB16(ImgRef<'data, rgb::RGB16>),
80 RGBA16(ImgRef<'data, rgb::RGBA16>),
81 GRAY8(ImgRef<'data, crate::export::rgb::GRAY8>),
82 GRAY16(ImgRef<'data, crate::export::rgb::GRAY16>),
83 GRAYA8(ImgRef<'data, crate::export::rgb::GRAYA8>),
84 GRAYA16(ImgRef<'data, crate::export::rgb::GRAYA16>),
85 }
86
87 #[derive(Debug, Clone, PartialEq, Eq)]
88 pub enum ImgVecKind {
89 RGB8(ImgVec<rgb::RGB8>),
90 RGBA8(ImgVec<rgb::RGBA8>),
91 RGB16(ImgVec<rgb::RGB16>),
92 RGBA16(ImgVec<rgb::RGBA16>),
93 GRAY8(ImgVec<crate::export::rgb::GRAY8>),
94 GRAY16(ImgVec<crate::export::rgb::GRAY16>),
95 GRAYA8(ImgVec<crate::export::rgb::GRAYA8>),
96 GRAYA16(ImgVec<crate::export::rgb::GRAYA16>),
97 }
98 }
99}