/// Attempt to get image format from file extension.
/// Stolen from https://docs.rs/image/0.22.1/src/image/dynimage.rs.html#755
Attempt to get image format from file extension.
Attempt to get image format from file extension .
fn guess_format(ext: &str) -> std::result::Result<image::ImageFormat, image::ImageError> {
    match ext {
        "jpg" | "jpeg" => Ok(image::ImageFormat::JPEG),
        "png" => Ok(image::ImageFormat::PNG),
        "gif" => Ok(image::ImageFormat::GIF),
        "webp" => Ok(image::ImageFormat::WEBP),
        "tif" | "tiff" => Ok(image::ImageFormat::TIFF),
        "tga" => Ok(image::ImageFormat::TGA),
        "bmp" => Ok(image::ImageFormat::BMP),
        "ico" => Ok(image::ImageFormat::ICO),
        "hdr" => Ok(image::ImageFormat::HDR),
        "pbm" | "pam" | "ppm" | "pgm" => Ok(image::ImageFormat::PNM),
        format => {
            return Err(image::ImageError::UnsupportedError(format!(
                "Image format image/{:?} is not supported.",
                format
            )))
        }
    }
}
fn guess_format ( ext : & str ) -> std :: result :: Result < image :: ImageFormat , image :: ImageError > { match ext { " " | " " => Ok ( image :: ImageFormat :: JPEG ) , " " => Ok ( image :: ImageFormat :: PNG ) , " " => Ok ( image :: ImageFormat :: GIF ) , " " => Ok ( image :: ImageFormat :: WEBP ) , " " | " " => Ok ( image :: ImageFormat :: TIFF ) , " " => Ok ( image :: ImageFormat :: TGA ) , " " => Ok ( image :: ImageFormat :: BMP ) , " " => Ok ( image :: ImageFormat :: ICO ) , " " => Ok ( image :: ImageFormat :: HDR ) , " " | " " | " " | " " => Ok ( image :: ImageFormat :: PNM ) , format => { return Err ( image :: ImageError :: UnsupportedError ( format ! ( " " format ) ) ) } } }
Attempt to get image format from file extension.
Attempt to get image format from file extension .
ext
&str