pub enum ImageFormat {
Unknown,
Png,
Jpeg,
Gif,
Bmp,
Tiff,
WebP,
}Expand description
Represents the underlying encoding format of an image.
Variants§
Unknown
No known encoding is known for the image.
This is usually because the image was created manually. See Image::set_format
to manually set the encoding format.
Png
The image is encoded in the PNG format.
Jpeg
The image is encoded in the JPEG format.
Gif
The image is encoded in the GIF format.
Bmp
The image is encoded in the BMP format.
Tiff
The image is encoded in the TIFF format.
WebP
The image is encoded in the WebP format.
Implementations§
Source§impl ImageFormat
impl ImageFormat
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Returns whether the extension is unknown.
Sourcepub fn from_extension(ext: impl AsRef<OsStr>) -> Result<ImageFormat, Error>
pub fn from_extension(ext: impl AsRef<OsStr>) -> Result<ImageFormat, Error>
Parses the given extension and returns the corresponding image format.
If the extension is an unknown extension, Ok(ImageFormat::Unknown) is returned.
If the extension is completely invalid and fails to be converted into a &str,
the InvalidExtension error is returned.
§Errors
- The extension is completely invalid and failed to be converted into a
&str.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<ImageFormat, Error>
pub fn from_path(path: impl AsRef<Path>) -> Result<ImageFormat, Error>
Returns the format specified by the given path.
This uses ImageFormat::from_extension to parse the extension.
This resolves via the extension of the path. See ImageFormat::infer_encoding for an
implementation that can resolve the format from the data.
§Errors
- No extension can be resolved from the path.
Sourcepub fn from_mime_type(mime: impl AsRef<str>) -> ImageFormat
pub fn from_mime_type(mime: impl AsRef<str>) -> ImageFormat
Returns the format specified by the given MIME type.
Sourcepub fn infer_encoding(sample: &[u8]) -> ImageFormat
pub fn infer_encoding(sample: &[u8]) -> ImageFormat
Infers the encoding format from the given data via a byte stream.
Sourcepub fn run_encoder<P>(
&self,
image: &Image<P>,
dest: impl Write,
) -> Result<(), Error>where
P: Pixel,
pub fn run_encoder<P>(
&self,
image: &Image<P>,
dest: impl Write,
) -> Result<(), Error>where
P: Pixel,
Sourcepub fn run_sequence_encoder<P>(
&self,
seq: &ImageSequence<P>,
dest: impl Write,
) -> Result<(), Error>where
P: Pixel,
pub fn run_sequence_encoder<P>(
&self,
seq: &ImageSequence<P>,
dest: impl Write,
) -> Result<(), Error>where
P: Pixel,
Sourcepub fn run_sequence_decoder<'a, P, R>(
&self,
stream: R,
) -> Result<Box<dyn FrameIterator<P, Item = Result<Frame<P>, Error>> + 'a>, Error>
pub fn run_sequence_decoder<'a, P, R>( &self, stream: R, ) -> Result<Box<dyn FrameIterator<P, Item = Result<Frame<P>, Error>> + 'a>, Error>
Trait Implementations§
Source§impl Clone for ImageFormat
impl Clone for ImageFormat
Source§fn clone(&self) -> ImageFormat
fn clone(&self) -> ImageFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more