load_image 3.5.0-beta.1

Load PNG or JPEG with color profile support
Documentation
use quick_error::quick_error;
use std::collections::TryReserveError;
use std::io;

quick_error! {
    #[derive(Debug)]
    #[non_exhaustive]
    pub enum Error {
        Png(err: lodepng::Error) {
            from()
            display("lodepng: {}", err)
            source(err)
        }
        #[cfg(all(feature = "jpeg", not(feature = "mozjpeg")))]
        Jpeg(err: zune_jpeg::errors::DecodeErrors) {
            display("zune-jpeg: {}", err)
            source(err)
        }
        #[cfg(feature = "mozjpeg")]
        Jpeg(err: String) {
            display("mozjpeg: {}", err)
        }
        Io(err: io::Error) {
            from()
            display("I/O: {}", err)
            source(err)
            from(_e: TryReserveError) -> (io::Error::new(io::ErrorKind::OutOfMemory, "OOM"))
        }
        #[cfg(feature = "webp")]
        WebP {
            display("WebP decoding failed")
        }
        ImageTooLarge {
            display("Image is larger than the allowed maximum dimension")
        }
        UnsupportedJpeg {
            display("Unsupported JPEG")
        }
        UnsupportedFileFormat {
            display("This file doesn't look like any of the supported image formats")
        }
    }
}

#[cfg(all(feature = "jpeg", not(feature = "mozjpeg")))]
impl From<zune_jpeg::errors::DecodeErrors> for Error {
    #[cold]
    fn from(e: zune_jpeg::errors::DecodeErrors) -> Self {
        Self::Jpeg(e)
    }
}